Published

Using 301 Redirects

Using 301 redirects are a useful way to indicate visitors and search crawlers that a page has been moved permanently to another location.

This is especially important, for instance, when you move your site to another domain. Redirecting all the pages on the old domain to your new site will help Google or Bing crawlers to indicate your site has permanently moved avoiding SEO issues.

There is another case where you want to make use of 301redirects to avoid hurting your SEO, this is when you have more than one domain pointing to the same content.

In my case I have two domains: www.josefcobonnin.com and www.josebonnin.com pointing to this blog. I don’t want to eliminate the first domain, but if I don’t do it the search engines will consider the content duplicated and will impact my positioning on the search results. To avoid it we can make use again of the 301 redirects.

The way to implement 301 redirects with ASP.NET is very easy, what we do is to capture the requests we receive and add to the response the HTTP header Location with the new URL.

The next code should be added in the Global.asax file of our ASP.NET projects.