AIzaSyBUdrdGP3NJ1Cc5rt11VsM2E0LFsksOMb4
The HTTP response status code 301 Moved Permanently is used for permanent URL redirection, meaning current links or records using the URL that the response is received for should be updated. The new URL should be provided in the Location field included with the response. The 301 redirect is considered a best practice for upgrading users from HTTP to HTTPS.[1]
Client request:
GET /index.php HTTP/1.1 Host: www.example.org
Server response:
HTTP/1.1 301 Moved Permanently Location: http://www.example.org/index.asp
Here is an example using a .htaccess file to redirect a non-secure URL to a secure address without the leading "www":
RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] RewriteCond %{HTTPS} on RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ https://%1/$1 [R=301,L] RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://example.com/$1 [R,L]
Here is an example using a PHP redirect:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://example.com/newpage.html");
exit;
?>
Equivalently simple for an nginx configuration:
location /old/url/ { return 301 /new/url/; }
Here is one way to redirect using Express.js:
app.all("/old/url", (req, res) => { res.redirect(301, "/new/url"); });
Both Bing and Google recommend using a 301 redirect to change the URL of a page as it is shown in search engine results.[3][4]
![]() | This World Wide Web-related article is a stub. You can help defaultlogic.com resource by . |
Manage research, learning and skills at defaultLogic. Create an account using LinkedIn or facebook to manage and organize your Digital Marketing and Technology knowledge. defaultLogic works like a shopping cart for information -- helping you to save, discuss and share.
Visit defaultLogic's partner sites below: