Wednesday, August 29, 2007

What is 301 redirects & Why 301 redirects?

Do you understand the different between a 301 and 302 redirect?

A 301 redirect means any page has moved to a new location, permanently. A 302 redirect means, the move is temporary or in a webmaster's language, your request to the server to view any page has been completed.

Search engines need to figure out whether to keep the old page, or replace it with the one found at the new location. Use the wrong type of redirects, and the search engines' view of your website can get screwed up, badly.

Why does this matter? If you are moving a web page or an entire web site to a new location, e.g. if you change your domain name and you want visitors to be able to find your site. A redirect causes the user's browser to automatically forward from the old location to the new one.

There aren't too many situations where a 302 is appropriate. How often have you temporarily moved a page? It's much more common to move pages permanently. Nevertheless, it seems easier to create 302 redirects than 301s. You can use Javascript or a meta tag to create a 302.

Below are some of methods to implement 301 URL Redirection:

IIS Redirect

* In internet services manager, right click on the file or folder you wish to redirect
* Select the radio titled "a redirection to a URL".
* Enter the redirection page
* Check "The exact url entered above" and the "A permanent redirection for this resource"
* Click on 'Apply'

ColdFusion Redirect
<.cfheader statuscode="301" statustext="Moved permanently">
<.cfheader name="Location" value="http://www.new-url.com">

PHP Redirect
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>

ASP Redirect
<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently";
Response.AddHeader("Location","http://www.new-url.com/");
%>

ASP .NET Redirect


JSP (Java) Redirect
<%
response.setStatus(301);
response.setHeader( "Location", "http://www.new-url.com/" );
response.setHeader( "Connection", "close" );
%>

In order to redirect any domain, you need to do it throug .htaccess file provided you are using Apache webserver.

You can test the redirection using search engine friendly redirect checker.

You can also verify the Server header type of the redirected URLs to confirm the 301 redirects.

No comments: