How to 301 permanent redirect for SEO

Redirecting from non-www domains to www domains (such as 301 redirection – permanent) is very important for ranking on search engines such as Google and it's also important to make sure that you're getting traffic from old locations to new.

So what's a 301 redirect, you ask?   Say for example, you're moving your site from one domain to another.  You wouldn't want to lose all of the traffic on your current site.  Instead, you want to keep that traffic, plus get traffic from the new site.  That's where a 301 redirect comes in.  It's basically a simple way for the internet to tell site visitors "don't visit the page here, visit it here instead".  When the user types in the URL of the old site, it redirects the visitor to the new site.  

Search engines consider to be a different from This is an important search consideration, so it's critical that your technical team creates the site direction  both with and without the www prefix.    

It's better to have every link used in exactly the same form as your domain. For this purpose, it is common to configure the redirect request from non-www side to www side.

It can be done in a number of ways but in this written tutorial, we will just focus on ASP.Net. Here are two simple solutions.

1. web.config : 

This is the most common practice because the IIS access is on the shared hosting environment.

Make sure you replace with the name of your domain.





        <rule name="Redirect to WWW" stopProcessing="true">

          <match url=".*" />


            <add input="{HTTP_HOST}" pattern="^$" />


          <action type="Redirect" url="{R:0}"

                  redirectType="Permanent" />







2. Global.asax.cs:

If you wish to redirect  within your application, use the Application_BeginRequest in Global.asax.cs to intercept the request and do a 301 (permanent) redirection on the URL. 

NOTE:you will need to set up the bindings of the site in IIS to accept both the and host names.

protected void Application_BeginRequest(object sender, EventArgs ev)


   string FromHomeURL = "";

   string ToHomeURL = "";




       HttpContext.Current.Response.Status = "301 Moved Permanently";


       Request.Url.ToString().ToLower().Replace(FromHomeURL, ToHomeURL));




Would you like your site more SEO friendly?  Fast Track is here to help. Contact us today and let's begin this journey.

View User Profile for Shubhada Paranjape Shubhada worked as a team lead for the Objectstar testing group (a product of Fujitsu) for two years. Later, she was the product lead for the e-filing development and support team for two years. Shubhada then joined Brian and her husband Ajey to start and run the Fast Track India operations. She holds a Masters in Mathematics from Pune University and an advanced diploma in Computer Science. She's on Twitter as @ShubhadaPar.
Posted by Shubhada Paranjape Friday, May 15, 2015 9:02:00 PM Categories: web development website