In SEO terminology, a 301 permanent redirect is the most search engine friendly method for webpage redirection. There are various reasons as to why you need this type of 301 permanent redirect. A typical scenario would be you create a website having lets say 5 pages. You launch it and it starts getting visitors. Now suddenly the business requires to replace the website and build a new more interactive website having new structure. Now since this website was already live and you had visitors to your previous 5 pages, a change in structure would mean these 5 indexed pages can not be found by search engines. This will in turn hit the rankings of your website. This is where a 301 permanent redirect comes into picture. It is a friendly way to let search engines know that sorry this page is no more active and the new location is this page.
Another reason to use this type of permanent redirect is to let search engines know the destination when an invalid indexed URL is looked for like redirecting the users to a standard page which says the resource you are looking for cannot be found.
It is in fact very easy to implement a 301 permanent redirect to your pages and this solution will also preserve your search engine rankings for that particular page. It is no doubt the safest option to change file names or move pages around. The "301" code is interpreted as "Moved Permanently". Since the websites can be built in various different technologies, the 301 permannent redirect implementation is also different. It can be implemented at server level or page level.
Mentioned below are various methods to implement URL Redirection via code or htaccess redirect.
<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://mynewlocationexample.com">
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://mynewlocationexample.com" );
<%@ Language=VBScript %>
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://mynewlocationexample.com"
private void Page_Load(object sender, System.EventArgs e)
Response.Status = "301 Moved Permanently";
response.setHeader( "Location", "http://mynewlocationexample.com" );
response.setHeader( "Connection", "close" );
$q = new CGI;
Ruby on Rails
headers["Status"] = "301 Moved Permanently"
Using .htaccess file
Create .htaccess file in the root directory with the following code. This method only works on Linux server having Apache Mod-Rewrite module.
RewriteRule (.*) http://mynewlocationexample.com/$1 [R=301,L]
These are some of the commonly used methods to implement 301 permanent redirect.