301 Redirect – Comprehensive Guide to URL Redirection

Canonical URLs and issues with URL redirection have been a major concern for most webmasters. While many webmasters have been badly bitten by the canonical URL issue, some others who tried to implement a redirection ( to avoid canonical issues) but couldn’t implement it properly are often bitten as hard, or even worse.

Though Google has implemented an option for suggesting the preferred URL in their Webmaster Central, where a webmaster can log in and specify the URL form that he wants Google to consider, the other major search engines are yet to reach that point. Also, there are still many webmasters who are not aware of this feature offered by Google’s Webmaster Central.

In addition URL redirection can be a very useful method in various other occasion, particularly if you are moving your site or re-developing it – that causes change in URLs that are already indexed by the search engines. I am sure none of us want to take the pain to start from scratch to work with new URLs or to lose all the back links that your old site might have earned through the years. Effective URL redirection can actually save you from all these.

I have tried to create a comprehensive guide on the types of redirection and the ways to implement them.

 

Types of Redirection

 

    • 301 Redirection – This is the most SEO Friendly redirection. This is actually a function of the web server that redirects a visitor from the current page to the new page and returns a response code that says that the original page has been Permanently moved to the new location. Search engines identify this redirection very easily and credit the new URL with all the back links and PageRank of the old URL. This type of redirection is expected to have the least impact on the search rankings.

 

    • 302 Redirection – A 302 redirection should be used when you want to redirect your visitors to a new page for temporary period. This is a function of the webserver that redirects visitors to the original page to a new page and send a response code that says that the page has been Temporarily moved to the new location. Search engines often have trouble to decide on how to treat this type of redirection and this can actually effect your search rankings. It is advisable that you try to avoid 302 redirection as much as possible (unless it is actually a temporary move).

 

    • Meta Redirect – This is a client side function done using the Meta-refresh tag. Traditionally it was believed that use of Meta-refresh tag might lead to penalty or ban from the search engines because of the immense misuse of this feature by several sites that served a keyword rich optimized page to the search engines and then redirected the users to the actual page. However, as per recent updates it seems search engines are a little better in handling this type of redirects but the concern is most of them are having a different policy on how they treat this redirects. Most of them though treat this as a form of 302 redirection and hence it is not at all recommended, if you have SEO in mind.Though there is no official statement from Google , from the word of mouth information it appears that they treat a Meta redirect as 302 redirection. Yahoo however, has clearly outlined there policy about handling redirections, stating that they treat Meta redirects set to 0 seconds (“little or no delay”) as 301 redirection and anything above 0 seconds (“noticeable delay”)is treated as a 302 redirection. MSN does not drop the original URL from their index on adding the Meta Refresh tag but also indexes the new URL, which indicates that they are treating Meta Redirection as 302 redirect.

 

 

How To Implement 301 Redirection / Website redirection

 

Redirection can be implemented at two levels. Server Side redirection can be either a 301 redirection or a 302 redirection, however, as 301 redirection is the most search engine friendly method, I have explained the 301 redirection only in this article.

 

 

 

 

 

 

 

 

 

 

Meta Redirect ( Using Meta Refresh Tag)

 

 

 

Add this line in between HEAD tags of your webpage to redirect that page in 0 seconds to http://www.newurl.com. You can increase the delay in redirection by changing “0” to some other value. Remember to replace http://www.newurl.com with the actual URL of your new page.

 

JavaScript Redirect ( NOT RECOMMENDED !! )

JavaScript redirection is another common form of client side redirection however it is not at all recommended from SEO perspective. In most cases the search engines would simply ignore trhe JavaScript and stay on the current phase. In most cases JavaScript redirects are not looked upon as a favorable practice as this technique has been massively misused by certain industries. The common trick was to have a keyword stuffed pages redirecting to the actual page in 0 seconds. The search engines would not be able to read the JS and index the keyword stuffed pages where as the visitors would be redirected to the actual page by the JavaScript. Search engines today are smart enough to detect this ploy and you can run into deep trouble if you are trying to utilize this.

 

Option 1

<script type=”text/javascript”><br><br><!–<br><br>window.location = “http://www.newurl.com/”<br><br>//–><br><br></script>

Option 2

 

Once again, JavaScript Redirect is Not Recommended from SEO Perspective.

Server Side Redirection

<strong><a name=”php”></a>301 Redirection in PHP </strong>

The code below should be added at the top of the page.

header(“HTTP/1.1 301 Moved Permanently”);

header(“Location: http://www.newurl.com”);

exit();

&nbsp;

 

301 Redirection in ASP ( VB Script )

<%@ Language=VBScript %>

<%

Response.Status=”301 Moved Permanently”

Response.AddHeader “Location”, “http://www.newurl.com”

response.end

%>

 

301 Redirection in ASP ( JScript )

The function below is dependent on the default feature of IIS 5 and above, where “Response.Buffer = true;” is set by default.This should be set before the function is called else it will cause errors.

function PermanentRedirect(strDestinationUri) {

Response.Clear();

Response.Status = 301;

Response.AddHeader(“Location”, strDestinationUri);

Response.Flush();

Response.End();

}

 

“strDestinationUri” should be an absolute URL for maximum client compatibility.

 

301 Redirection in ASP.Net ( C# )

 

301 Redirection in Cold Fusion ( CFM )

<.cfheader statuscode=”301″ statustext=”Moved permanently”>

<.cfheader name=”Location” value=”http://www.newurl.com”>

 

301 Redirection in JSP / JAVA

<%

response.setStatus(301);

response.setHeader( “Location”, “http://www.newurl.com” );

response.setHeader( “Connection”, “close” );

%>

 

Redirection scripts are extremely important and can be very helpful if applied properly not just for 301 redirection or URL canonicalization issues but also to resolve several situation specific problems. In all cases server level redirections should be the first option and client side redirection should be considered in cases only when you do not have control over your server.

Read more on SEO at SEO Consultant India Blog

About "" Has 249 Posts

Check out the About SRC Page for more details about Saptarshi Roy Chaudhury.

7 Comments to “301 Redirect – Comprehensive Guide to URL Redirection”

  1. seo-kolkata says:

    I got an email from Mr.David Stern today about some redirection issues that he needs to take care of. I replied him in email but thought it would be a nce addition to this post. So here it is…

    Mail from David Stern
    ====================
    Hello, I saw your recent article at http://seo-kolkata.blogspot.com/
    2007/04/301-redirect-comprehensive-guide-to-url.html and I was hoping
    you had time for a question.

    I have six parked domains pointing to ns1.s500.myserver.com (and
    ns2). I have created matching subdomains at mydomain.com for each
    parked domain to be redirected to. For example, I want requests for
    http://www.dgh1.com to be redirected to http://dgh1.mydomain.com.
    What is the best way to do this? My hosting provider says they don’t
    provide that service but I’m convinced I can do it anyway.
    Currently, when one goes to http://www.dgh1.com, the address bar
    shows that URL even though it is going to http://www.mydomain.com (is
    there some sort of URL detect I can use?)

    So, basically, I want this to happen:

    http://www.dgh1.com —> http://dgh1.mydomain.com
    http://www.dgh2.com —> http://dgh2.mydomain.com
    http://www.dgh3.com —> http://dgh3.mydomain.com
    http://www.dgh4.com —> http://dgh4.mydomain.com
    http://www.dgh5.com —> http://dgh5.mydomain.com
    http://www.dgh6.com —> http://dgh6.mydomain.com

    but I want requests for http://www.mydomain.com to be handled normally.

    Thanks in advance. Your help is greatly appreciated.

    David Stern

    PS: the registrar wants $5 per domain to forward to a specific URL.
    I want to avoid any other fees.
    =========================

    My Suggestions to David
    =========================
    The situation is a bit difficult for you because to run a redirection script you will actually need to have a page and the page needs to be hosted. I understand hosting six pages might be an expensive affair.Neither can you implement a custom script on a parking page ( correct me if I am wrong, I haven’t come across any host who give access to the parking pages ) So the chance of getting your pages redirected is very bleak. What the hosting companies provide are basically domain pointing ( often a 302 redirect).

    Also, it is important to know the purpose of the redirection and how you want these subdomains and ancillary domains (dgh1.com, dgh2.com etc) to be treated by the search engines in order to give you proper suggestions. However, assuming that you want to do a 301 redirect for all those domains to the subdomains, here are my suggestions.

    There are two options that I can suggest, which might be relatively cheaper and safe

    a) Get a hosting that allows multiple domain hosting. Put all 6 domains there. Add a ASP/PHP page as index.asp/index.php etc and put up a 301 script to redirect to the respective subdomains. You can copy and modify the code given in my blog or let me know if you need help with that.

    b) Get a hosting for http://www.dgh1.com and use a 301 redirect to http://dgh1.mydomain.com.Besides, write a script on that page that identifies referrer URL and use the corresponding redirect location for the 301 script.Then point all the other domains to http://www.dgh1.com.

    This sounds very complicated, so let me explain with an example..

    When this has been implemented, if a visitor lands at http://www.dgh2.com he is sent to http://www.dgh1.com due to URL pointing by the hosting company. The script at http://www.dgh1.com identifies the referrer URL as http://www.dgh2.com and replaces the redirect location in the 301 script with http://dgh2.mydomain.com. Similarly for a visitor coming from http://www.dgh3.com the visitro is ultimately redirected to http://dgh3.mydomain.com and so on.

    This would require a good level of scripting knowledge.

    (** added now: I have not implemented this before but I don’t see any reason why this should not be possible.)
    ==========================

  2. diego says:

    Hello, I saw your recent article at http://seo-kolkata.blogspot.com/
    2007/04/301 -redirect-comprehensive-guide-to-url.html and I was hoping
    you had time for a question.

    i want to move this blogpost:

    http://www.domain111.com/?p=23

    to this:
    http://www.domain222.com/category/updates/

    that is some example of what i want to do. its a blogpost, i know that this is posible with .htacess but i dont know really.
    thank very much

    im working with wordpress and i have mod_rewrite enabled on my server(godaddy)

  3. seo-kolkata says:

    Hi Diego,

    if you are using WordPress , you dont even need to do a 301 redirect for this. You are actually using the default permalink option on your blog so you get URLs like http://www.domain111.com/?p=23 . Log in to your WP admin section >> Click on Manage >> Click on permalinks. Click the radio button “Custom, Specify below” and then in the field below put in /%category%/%postname%/ After this click on Update Permalink Structure and your URLs would be changed to http://www.domain222.com/category/updates/ format

  4. Diego says:

    well, but i want to move the post to another domain, thats why i want a 301 redirect.
    so the domain222.com is another blog.

  5. seo-kolkata says:

    Sorry, I missed the different domain part and just looked at the permalink struture.

    It is pretty simple to move from one domain to other.. all you need to write is

    Options +FollowSymLinks
    RewriteEngine on

    RewriteCond %{HTTP_HOST} ^domain.com [NC]
    RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

    This would redirect all your previous domain URLs to corresponding URL in new domains. But you have also changed the permalink struture which has changed the URL, so you will actually need to do some more work. Besides the above code, you can use the WP Permalink redirection plugin at http://wordpress.org/extend/plugins/permalinks-moved-permanently/#post-2209 and ensure that the you have dumpled your old WP DB onto the new domain.

    Once you have done this, when someone types in http://www.domain.com/?p=23 he should be redirected to http://www.newdomain.com/?p=23 and then the plugin would redirect http://www.newdomain.com/?p=23 to the corresponding URL which would be in format of http://www.newdomain.com/category/postname

    I a sure there is some other way to do this eve without using that plugin, but I will have to do some more research to find that out, in case I come across any I will post it here. In the mean time you can try the method i suggested above.

    ** important: always keep back up of all files when working with .htaccess and 301 redirections just to avoid any unwanted situation.

    hope this helps 🙂

  6. SNVC says:

    This is definitely a good guide. Thanks for this.

  7. Niksss...... says:

    hey thanx for your post.. I really liked it… I have a question for you..
    Actually I am doing seo for my own website. But there is a very nice query i want to ask… i.e.
    suppose my website provides information about indian hotels and my main url is http://www.mycompanyname.com but for SEO perspective Keyword rich url is also very important.
    so, I want that google crawl my url as http://www.best-indian-hotels.com which will be seen in search result.
    I want if any user searches for “best indian hotels” and he/she finds http://www.best-indian-hotels.com on top. when he/she clicks on it, he/she should be redirected to my original company’s name url ie. http://www.mycompanyname.com
    Is it possible?? Would it be SEO friendly or It is a bad practice??

    I know this is a very stupid question but please answer me this question. I am really confuse about it.
    I will be thankful to you.
    I just want my website on top 10. Please help me in this…. [;)]

    reply me soon..
    Thanks in advance

    Niksss……

Leave a Reply

Your email address will not be published. Required fields are marked *