URL Rewrite Module for IIS7

At my workplace we had a project in beta for a while, and the address was something like beta.domain.com, and yesterday we finally released it to the public. The site in beta.domain.com has replaced the old site at www.domain.com, so we had to find a way to redirect all the users from beta.domain.com to www.domain.com.

We are running our site on a Windows 2008 R2 Standard OS, so we are using IIS 7.5.

My first attempt was with the HTTP Redirect module:

image

image

Basically I configured a 2nd website on my box, that respond to beta.domain.com and redirect all the calls to www.domain.com, and that kind of worked, but almost immediately I noticed a problem with it: it was not forwarding the query string from the beta domain to the live domain.

I decided to try with  URL Rewrite Module 2.0 for IIS 7 http://bit.ly/9MJy5J, so I fired up the Web Platform Installer, searched for the rewrite module and installed it.

image

It comes as a new feature in IIS.

image

Once you open the new feature, you can, with a few clicks, configure a canonical domain name that you want to use for that specific website, you can then configure multiple host names on the website and all the request will be 301 redirected to the unique canonical name that you really want to use for your site.

image

There’s obviously much more you can do with this URL Rewrite Module.
The module basically support all the configurations you can do with mod_rewrite in Apache, making http://www.isapirewrite.com/ obsolete.
On my home server I use it as a reverse proxy (when used in conjunction with Application Request Routing http://bit.ly/diPNwF) to redirect some custom domains to services hosted on other boxes I’ve got at home.

I invite you to read this list of articles http://learn.iis.net/page.aspx/737/url-rewrite-module-2/ to know more about it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s