URL Rewrite 2.0 for IIS 7 is here

We recently upgraded the IIS 7 servers with version 2.0 of the URL rewrite module.

I have to be honest – generally speaking, SEO & URL rewriting is not a topic that I often (ever) think about. The reality is, no matter how you write your URLs, if your site only has a handful of visitors, the format of your URLs is not going to matter. Your time would be much better spent improving your site, making it more useful and popular. So why spend time and energy on such a topic when there is so much other stuff to do? I think most people share this opinion. But that’s what makes this new version so interesting to me.

Yes, this is indeed a major upgrade, and the feature list is lengthy. But what “The rest of us” will be happy to know is that Microsoft has included templates that make this process much easier. These are essentially tiny wizards that allow you to plug in a couple values and let the tool deal with the rest.

The first thing you need to do is get the IIS 7 Manager add-in to control the service.  When you connect to the server using IIS 7 Manager you will be greeted with a window asking if you would like to install the add-in (if you have the old module already, you will be asked to upgrade when you connect).

Now, let’s try a few things and see how easy this is. Let’s assume that you want to redirect requests for YourHostedDomainName.com to www.YourHostedDomainName.com

  • In IIS 7 Manager, navigate to the URL Rewrite section
  • Click Add Rule on the right hand side
  • Click the canonical domain name template
  • Enter your domain name, including the www

That’s it. Done.

Next, let’s work on making some user-friendly URLs. Let’s assume for a moment that we have an application that generates URLs in the following manner:

http://www.YourHostedDomainName.com/application/default.aspx?id=123

And we wanted to rewrite the URL as:

http://www.YourHostedDomainName.com/123

  • In IIS 7 Manager, navigate to the URL Rewrite section
  • Click Add Rule on the right side
  • Click User-Friendly URL

You will notice that you have an option for how you want the URL to be rewritten. The best part is that it is generating the regular expressions and corresponding inbound/outbound rules required to perform the task automatically.

Another cool feature is that by clicking the Create corresponding outbound rewrite rule check box, any links with an unfriendly URL within your pages will also be rewritten.

So for example, let’s assume you had a page with the following link:

<a href=”Test”>http://www.YourHostedDomainName.com/application/default.aspx?id=123″>Test Link</a>

This link would automatically be rewritten on the fly and served as:

http://www.YourHostedDomainName.com/123

These two scenarios are what we get asked about most commonly. You can see how easily URL Rewrite 2.0 addresses them. And we have not even scratched the surface. This release is extremely deep and can be used to perform a multitude of tasks. If you want to work with some of the more complex operations, I suggest you visit the learning section of the IIS site.

Some of the key points that stand out are:

Access to server variables and http headers. Server variables and HTTP headers provide additional information about current HTTP request. This information can be used to make rewriting decisions or to compose the output URL.

Various rule actions. Instead of rewriting a URL, a rule may perform other actions, such as issue an HTTP redirect, abort the request, or send a custom status code to HTTP client.

Failed Request Tracing support. IIS 7 Failed Request Tracing can be used to troubleshoot errors related to URL rewriting.

GUI tool for importing of mod_rewrite rules. URL rewrite module includes a GUI tool for converting rewrite rules from mod_rewrite format into an IIS format.

Michael Ossou
Technical Support

2 thoughts on “URL Rewrite 2.0 for IIS 7 is here

  1. I assume this page is the IIS 7 Manager that you refer to in the set of instructions I pasted below: https://my.discountasp.net/web-manager/iis7-manager.aspx

    But I’m not seeing anything that refers to “URL Rewrite”. Am I on the wrong page? Am I overlooking something?

    •In IIS 7 Manager, navigate to the URL Rewrite section
    •Click Add Rule on the right hand side
    •Click the canonical domain name template
    •Enter your domain name, including the www

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.