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.

image

For more information on the SEO Templates look at: http://learn.iis.net/page.aspx/806/seo-rule-templates/

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 (http://www.carlosag.net/Tools/CodeTranslator/) and you will see URL Rewrite in action:

  1. http://www.carlosag.net/Tools/CodeTranslator/
  2. http://carlosag.net/Tools/CodeTranslator/
  3. http://www.carlosag.net/Tools/CodeTranslator

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"?>
<configuration>
   
<system.webServer>
       
<rewrite>
           
<rules>
               
<rule name="CanonicalHostNameRule1">
                   
<match url="(.*)" />
                    <
conditions>
                       
<add input="{HTTP_HOST}" pattern="^www\.carlosag\.net$" negate="true" />
                    </
conditions>
                   
<action type="Redirect" url="http://www.carlosag.net/{R:1}" />
                </
rule>
           
</rules>
       
</rewrite>
   
</system.webServer>
</configuration>

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