SEO made easy with IIS URL Rewrite 2.0 SEO templates

A few weeks ago my team released the version 2.0 of the URL Rewrite for IIS. URL Rewrite is probably the most powerful Rewrite engine for Web Applications. It gives you many features including Inbound Rewriting (ie. Rewrite the URL, Redirect to another URL, Abort Requests, use of Maps, and more), and in Version 2.0 it also includes Outbound Rewriting so that you can rewrite URLs or any markup as the content is being sent back even if its generated using PHP, ASP.NET or any other technology.

It also includes a very powerful User Interface that allows you to test your regular expressions and even better it includes a set of templates for common types of Rules. Some of those rules are incredibly valuable for SEO (Search Engine Optimization) purposes. The SEO rules are:

  1. Enforce Lowercase URLs. It will make sure that every URL is used with only lower case and if not it will redirect with a 301 to the lower-case version.

  2. Enforce a Canonical Domain Name. It will help you specify what domain name you want to use for your site and it will redirect the traffic to the right host name.

  3. Append or Remove the Trailing Slash. It will make sure your request either include or not include the trailing slash depending on your preference.


For more information on the SEO Templates look at:

What is really cool is that you can use the SEO Toolkit to run it against your application and you probably will get some violations around lower-case, or canonical domains, etc. And after seeing those you can use URL Rewrite 2.0 to fix them with one click.

I have personally used it in my Web site, try the following three URLs and all of them will be redirected to the canonical form ( and you will see URL Rewrite in action:




Note that at the end those templates just translate to web.config settings that become part of your application that can be XCOPY with it. This works with ASP.NET, PHP, or any other server technology including static files. Below is the output of the Canonical Host Name rule which I use on my Web site’s web.config.

<?xml version="1.0" encoding="UTF-8"?>
<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<add input="{HTTP_HOST}" pattern="^www\.carlosag\.net$" negate="true" />
<action type="Redirect" url="{R:1}" />

There are many more features that I could talk, but for now this was just a quick SEO related post.

Comments (8)

  1. Neil Palmer says:

    This is especially good for the case problem- I used to have a nightmare managing large e-commerce sites where the upper and lower case url’s were all mixed up.

  2. Mark Vozzo says:

    Hey Carlos,  

    We met at the xMS SEO Summit in Redmond a few weeks back.  I’m back in Sydney, Australia now but I came across this post and wanted to say "Thank You" it’s a great blog post, and I have passed it onto our dev team.

    Also, just wanted to say – I’m loving the IIS SEO Toolkit – Nice work 🙂   Please add me to a Beta Announcement list (if there is one).


    Mark Vozzo – Microsoft Australia

  3. RubenS says:


       We suggest putting Permanent redirect in the code:

                   <rule name="www" enabled="true" stopProcessing="true">

                       <match url="(.*)" />

                       <conditions logicalGrouping="MatchAll">

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


                       <action type="Redirect" url="{R:1}" redirectType="Permanent" />


    More info in Spanish at:

  4. SEO says:

    Very nice article.. worth reading it. Thank you for posting such a nice post about seo 😀

  5. CarlosAg says:

    @RubenS  Permanent redirect is the default in URL Rewrite so it is optional to add the type=Redirect. In the rule above it will be a permanent 301

  6. Tom Leeson says:

    Doh! – i did not select a website first and was unable for hours of removing and re-installing the software – to see the SEO Templates….  




    Website Level   -must select the website first then url rewrite

  7. ViruS says:

    I have a lil question about that.

    I need to remove all double or more slashes '///' of my url ends. My links are ok but external links from other website are not. wat rle can i use in my web.config to do that.

    Thanks a lot.

  8. Toronto SEO Gurus says:

    This is certainly a great blog post a few years later!

Skip to main content