Redirect Your URL Using IIS 7 and ASP.NET Web.config

by David on December 29, 2009

So here’s the situation – you have your domain name (ex: mydomain.com) and you want to improve your SEO rankings by redirecting the following two url’s to the same address…. http://mydomain.com and http://www.mydomain.com. So how do you do it on IIS 7 and using an ASP.NET application. FYI – I use a shared hosting (Windows platform) at GoDaddy and this solution works.  The following article best describes it. In a nutshell, you modify your web.config to handle the redirect. Check it out.

http://blogs.iis.net/carlosag/archive/2008/09/02/iis-7-0-and-url-rewrite-make-your-web-site-seo.aspx

Example: web.config

<configuration>
 
<system.webServer>
   
<rewrite>
     
<rules>
       
<rule name=”Redirect to WWW” stopProcessing=”true”>
         
<match url=”.*” />
          <
conditions>
           
<add input=”{HTTP_HOST}” pattern=”^mydomain.com$” />
          </
conditions>
         
<action type=”Redirect” url=”http://www.mydomain.com/{R:0}” redirectType=”Permanent” />
        </
rule>
     
</rules>
   
</rewrite>
 
</system.webServer>
</configuration>

Now when you hit http://mydomain.com you will be redirected to http://www.mydomain.com and your SEO rankings will not take a hit for having two ambiguous addresses.  I hope this helps!

Comments on this entry are closed.

Previous post: