301 permanent Redirect
There comes a time in every webmasters life when they need to redirect a user to a different page. This could be because you have moved your pages around to improve your sites structure, Or because you have deleted a page and don't want your visitors to see a 404 error message.
Now, the safest way to redirect visitors and bots is to use a permanent 301 redirect, A permanent 301 redirect sends a status code to the browser, or bot, to inform them that this page has moved, and is not coming back and that there is a new replacement page they should be looking at. We call this the safest way to redirect users because spider bots understand this status code, they will follow it and eventually pass over rank to the new page.
In this small tutorial we will cover the various ways you can achieve a 301 redirect using different languages and different methods.
Redirect visitors and bots from a subdomain to a domain with a 301 redirect
New webmasters are told to only point links to one place, It is important that all of your backlinks go to the same URL.
Remember, www.domain.com domain.com, www.domain.com/index.html and domain.com/index.html are not the same page, they will be seen as different pages,, and in the case of WWW Vs non WWW they will be seen as different websites.
This can partly be overcome by using a 301 redirect to send visitors and spider bots who go to domain.com to www.domain..com, And we achieve this with an .htaccess file that sends a 301 redirect status..
Or if your host doesn't allow mod_rewrite, You can use this code in an .htaccess file
PHP 301 Redirect
You can also send a 301 status code with PHP. To do this, put the following code in the PHP file you wish to redirect from.
ASP 301 Redirect
finally we will look at the ASP 301 redirect, That is achieved with the following code in your ASP file.
The ASP redirect could look something like this:
(easiest way is to put it in the global.asa)
If Request.ServerVariables("PATH_INFO")= "/oldfile.htm" Then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.domain.com/newfile.htm"
End if
Post a Comment