Categories: .Net SEO Posted on 5/8/2009 7:11 PM by Ryan Shelby  Feedback (14)

This blog post is more of a future reference for myself.  Anytime I create a new site I use it, but I can never remember the syntax.

 

To search engines,  it's no good if your homepage can be shown under several URLs. Consider the 4 different ways someone could view the rshelby.com homepage:

All 4 examples listed above lead to the same page.  However since they each have a different URL, search engines may view them as several pages with the same content.  It is known that Google has penalties for duplicate content.

 

Another issue is when people link to your site.  Quite often they copy and past the URL of your homepage from the address bar.  As a result your inbound links might not all be the same, and you may not get the full benefit of the links going to your homepage. 

 

A perfect example of this is www.vectorlight.netwww.vectorlight.net currently has a Google Page Rank of 4, while www.vectorlight.net/default.aspx has a rank of 2.  It's the exact same page.  Could Vectorlight really have a page rank of 5 if all roads lead to www.vectorlight.net?

 

To eliminate this potential problem, I use the IIS 7 Rewrite Module to force all 4 scenarios to use the one URL of my choice [that would be www.rshelby.com/].  IIS 7 Rewrite Module must be installed on your webserver in order to use it.  It can be downloaded at IIS 7 Rewrite Module.

 

The nice thing about it is you can define everything in the System.webServer namespace within your Web.Config file.  This makes life very easy in a shared hosting environment if you don't have access to the IIS 7 Rewrite Module user interface.

 

To force a 301 redirect from non-www to www:

 

    1 <system.webServer>
    2   <rewrite>
    3     <rules>
    4       <rule name="Redirect to WWW" stopProcessing="true">
    5         <match url=".*"/>
    6         <conditions>
    7           <add input="{HTTP_HOST}" pattern="^yourwebsite.com$"/>
    8         </conditions>
    9         <action type="Redirect" url="http://www.yourwebsite.com/{R:0}" redirectType="Permanent"/>
   10       </rule>
   11     </rules>
   12   </rewrite>
   13 </system.webServer>

 

 

To force a 301 redirect from www to non-www, change the rule to.

 

    1 <rule name="Redirect to NON-WWW" stopProcessing="true">
    2   <match url=".*" />
    3   <conditions>
    4     <add input="{HTTP_HOST}" pattern="^www.yourwebsite.com$" />
    5   </conditions>
    6   <action type="Redirect" url="http://yourwebsite.com/{R:0}" redirectType="Permanent" />
    7 </rule>

 

 

To force a 301 redirect from the Default.aspx to extensionless URL "/":

 

    1 <rule name="Default Document" stopProcessing="true">
    2   <match url="(.*)default.aspx"/>
    3   <action type="Redirect" url="{R:1}" redirectType="Permanent"/>
    4 </rule>

 

Since I'm using BlogEngine.NET software, it's much easier to use the builtin feature that can handle the www to non-www (or vice versa) redirect issue more easily.  If you apply the Default Document rule in BlogEngine.NET, it won't let you sign in or out from the homepage.

 

At any rate, I was able to apply these rules pretty easily to my wife's salon website and it worked great.  Try clicking on the following links and you'll see the IIS 7 Rewrite Module in action:

 

Even though the URL being requested is not the same, it still rewrites it as [www.hairsalonmichigan.com/]!

 

Comments

SEO
SEO on 6/24/2009 2:18 AM
I have been associated with SEO work for a long time now.but never knew about this.thanks for sharing it.
Koral
Koral on 7/13/2009 2:30 PM It looks like an effective way to do 301 redirects. Thanks for hosting this information, Ryan.
Las vegas web designer
Las vegas web designer on 7/28/2009 3:07 PM URL's are a hugely important factor when it comes to SEO.  Tips like these are what make you stand above your competition.
Rohit Kumar
Rohit Kumar on 8/1/2009 12:37 AM Hi,

   Thanks for sharing such great seo trick with us, I have a question in my mind weather this will also work for simple html websites.
Krystyna
Krystyna on 8/4/2009 9:57 PM Ryan,

An excellent set of instructions which I'll use on my present project. Question: How does one set up redirects for individual pages? I don't have access to the IIS server, so I'll have to do the redirects using a method as you describe above. The problem with this site is - there are 80 or so pages to redirect (yikes).
Ryan Shelby
Ryan Shelby on 8/5/2009 9:19 AM Thanks Krystyna.  You can perform a 301 redirect from old page requests by inserting the rule below (the "\" between the OldWebPage and aspx is not an error):

<rule name="Redirect Old Page To New Page" stopProcessing="true">
  <match url="OldWebPage\.aspx"/>
  <action type="Redirect" url="NewWebpage.aspx" redirectType="Permanent"/>
</rule>

Good luck!
Press release writer
Press release writer on 8/17/2009 5:11 PM Some very useful hints there. I'm glad I found this site. This might come in handy sometime. Great post!
Johny
Johny on 8/21/2009 1:09 PM thanks for this nice info, it's so useful for me.
Cosmetic fillers Philadelphia
Cosmetic fillers Philadelphia on 8/26/2009 12:32 PM Hi Ryan. I'm using SEO too and  I love your article. I will install IIS 7 Rewrite Module right away. Thanks for sharing!
Fred roines
Fred roines on 8/30/2009 11:11 AM Hi,

So , what and how would be to 5th scenario,

how to force to http://mysite.com/ when it is
http://mysite.com/temp/?

Could you please give us example?

best regards
F.

Indianapolis SEO
Indianapolis SEO on 9/12/2009 2:14 PM Thanks for sharing this seo tip. I like how you showed that we could force all 4 url scenarios through the rewrite to use the url of our choice. That is very helpful to prevent duplicate content. Good info.
Web design
Web design on 9/16/2009 3:29 AM
Thanks for that really clear explanation of a pretty cloudy topic! SEO is such a specialized area, that not many developers give it the attention it deserves. With regard to Google, one area that concerns me most is that of being penalized for duplicate content as this seems to me to be something quite easy to fall into unawares. The question then arises of what type of penalty is imposed and how can we detect that this is the case.
seo tampa
seo tampa on 9/24/2009 3:13 AM This is great. I have to implement this immediately.
carolinasdahliasociety
carolinasdahliasociety on 9/30/2009 10:58 AM SEO Friendly Homepages using IIS 7 Rewrite Module  , grabbed my attention. I have  started out to develop using Silverlight but I am finding it is a large learning curve.  My earlier experience is with mysql, php, most linux based tools and flash. The challenges of utilising Silverlight to produce a clear layout that functions rapidly in all the major web browsers, IE, Firefox, Safari and Chrome can be a big headache that is taking me numerous hours to solve.  Absorbing to read your thoughts and the remarks in your website on Silverlight.  I feel the tutorial sites and Microsofts offering are strict and address the same items, discussion in web logs often covers actual ways to beat problems that takes me through the learning curve more quickly.  Thanks for the post, it has helped in a small way to take me through the migration.
Comments are closed