On the World Wide Web, HTTP 301, or 301 Moved Permanently, is the HTTP status code used for permanent redirecting. It means that links or records to this URL should be updated to the destination provided in the Location field of the server response. The 301 redirect is considered a best practice for upgrading users from HTTP to HTTPS.
RFC 2616 states that:
Client request:
Server response:
To fix problems with non-existing files or directories using a distributed .htaccess file:
Here is an example using a .htaccess file to redirect a non-secure URL to a secure address without the leading "www":
A custom directory redirect, using an index.html file:
Here is an example using Perl CGI.pm:
Here is an example using a PHP redirect:
Here is one way to redirect using Express.js:
Equivalently simple for an nginx configuration:
Both Bing and Google recommend using a 301 redirect to change the URL of a page as it is shown in search engine results, providing that URL will permanently change and is not due to be changed again any time soon.