Canonical URLs help you to make your links Search Engine Optimized (SEO). For human it is easy to understand that is same as But many search engines will not make this assumption and treat them as two separate entries. This will split the rankings among them and lower the overall relevance of the site.

In IIS7.0 you can use URL Rewrite to solve this problem. The following rule when added in the "Web.config" file in the root of your web site will automatically direct all the people using to

        <rule name="WWW Redirect" stopProcessing="true">
          <match url=".*" />
            <add input="{HTTP_HOST}" pattern="^$" />
          <action type="Redirect" url="{R:0}" 
redirectType="Permanent" />
</PRE< P>


One important thing to remember is to use "Permanent" redirects. This will be helpful if anybody who has linked your page using a non WWW URL. Doing this will direct search engine bot crawls to treat the link as permanently moved. The new URL will be identified as the correct address hence old non WWW URL will not be indexed.

I have just pasted the XML code but the same thing can be achieved using the URL Rewrite GUI which comes with IIS Manager.

Open IIS Manager.


Click on URL Rewrite.


Click on Add Rules->Blank Rule.


Give a pattern you would like to match, change the “Action type” to “Redirect” and specify the redirect URL. This will add the same content to the config file as shown above.

One important thing to remember is that URL Rewrite should be installed for this to work. You can install X86 version here and X64 here. This module is supported for IIS 7.0 and you should be running IIS 7.0 to take advantage of it. Also if you are working with VWD (Visual Studio for Web Developers) your project should be configured to work with IIS 7.0 and not any other web server.

For details about URL Rewrite module please look here.

Don Raman