Canonical URL and URL redirection issues is a major concern for most webmasters. Although many administrators are evil bitten by the original address the problem, others who were trying to make a redirect (to avoid canonical problems), but could not be conducted properly often bite so strong, or even worse.
While Google has the opportunity to bring their favorite URL Webmaster Central, where the administrator can access and specify the URL of the form that he wants Google, other search engines have not yet reached this point. In addition, there are still many webmasters who are not familiar with this feature that Google Webmaster Central. In addition, the redirection URL can be a useful method for various other situations, especially if you access a website or re-development - that causes a change of URLs already indexed by search engines. I am sure none of us wants to take the pain to start from scratch with the new addresses, or lose all your links to the old site probably deserved years. effective URL redirection can actually save them all.
I tried to create a comprehensive guide for redirection, and ways to implement them.
Types of Redirection
* 301 Redirect
This is the most SEO friendly redirect. It is actually a web server function that redirects the visitor of the current page to the new page and returns a response code that says the original site has been permanently moved to the new location. Search engines identify the redirection is very easy and credit of the new URL with all the back links and PageRank of the old URL. This type of diversion is expected to have any influence on search rankings.
Example:
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">
<!--
window.location = "http://www.newurl.com/"
//-->
</script>
Option 2
<body onLoad="setTimeout(location.href='http://www.newurl.com', '0')" >
Once again, JavaScript Redirect is Not Recommended from SEO Perspective.
Server Side Redirection
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();
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# )
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.newurl.com");
}
</script>
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" );
%>
* 302 Redirect
A 302 redirect should be used when you want to redirect visitors to a new page for the time period. Is a function of web server that redirects visitors to the original page to a new page and send a response code that says the page was temporarily moved to the new location. Search engines often have difficulty deciding on how to treat this type of redirection, can actually affect your search ranking. It is advisable to try to avoid the 302 redirect as much as possible (unless it is really a temporary measure).
* 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.
Example:
Meta Redirect ( Using Meta Refresh Tag)
<META HTTP-EQUIV=Refresh CONTENT="0; URL=http://www.newurl.com">
Add this line in between <head></head> 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.
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.
Choose wisely mentioned above code.
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.