Search Engine Friendly Permanent 301 Redirects with asp.net
Getting a website indexed with a search engine can be a long process. It can take ages for the bot to get around to indexing all your content, and can take even longer to build your sites reputation and page rank.
Therefore, when existing pages are replaced or moved, many a good asp.net developer will use the famous asp.net response.redirect
function to redirect the user from the old page to the new page.
Say we’ve moved http://www.mysite.com/help.aspx
to a new section http://www.mysite.com/help/default.aspx
. We leave the help.aspx page where it is, but in the help.aspx.vb code behind page we simply add the line:
page.response.redirect("/help/default.aspx", false)
This is great, the user will go to the new page, and the old content will never be seen.
But, and this is a big but, what if the search engine has indexed the original page?
In its vast database it holds an entry for our original http://www.mysite.com/help.aspx
page. When it comes back to re-index your site, it will not only recognise the redirect as temporary (302) relocation of the page. Using a permanent (301) redirect will tell the search engine (or web browser) that the page has permanently moved, and that it should go to the new page:
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.mysite.com/help/default.aspx");
}
You will see that no redirection actually occurs, we are simply writing headers to the browser/search engine that tells it that the page has moved permanently. When the search engine nexts indexes your site, it should recognise this change, and update its records accordingly. This means that your existing search engine ranking will be preserved.
I have recently updated a site with a brand new design where every page on the old site had been replaced with newer pages. At the time, I did not redirect the old pages to the new ones. In fact it took me 3 weeks to get around to the job, but when I did, the traffic increased by 40% to the site simply because it was benefitting from all the older search engine links also. Lesson learned for me. Next time I’ll prepare all the redirect before putting a new site live.