Sep 04 2008
Creating HTTP Redirects in IIS6
We’re putting the finishing touches on a new web site for a client. The new pages are in place on the test server and load testing is about to begin. Everything is going great. “Oh, we almost forgot to mention that every URL from the previous site has to be permanently redirected to the new site.”
Knowing that this is easy in Apache, I agreed that this could be quickly accomplished with IIS and that we’d be able to get this in place before the site goes live in two weeks.
Unfortunately, I was mistaken. This is not easily accomplished in the IIS control panel, and impossible when the URLs do not exist. Instead, it’s necessary to use the IIS Metabase Explorer from the IIS 6 Resource Kit.
Download and install the IIS 6 Resource Kit Tools from Microsoft (Internet Information Services (IIS) 6.0 Resource Kit Tools). Once you have installed it, launch the installer and walk through the installation wizard, just like you would for anything else.
You should end up with multiple new menu entries:

Fire up the IIS Metabase Explorer and navigate to your local website. In my case I used the root website, so I opened up [MACHINE NAME]\LM\W3SVC\1\ROOT. So far, this should look similar to what you would see in the IIS Administration Console.
Right click on ROOT and select New > Key. A new key equates to either a file or directory - at least for the purposes of this tutorial. Name this key facility9.html - we’re going to send me some more traffic. Once you have created the key, right click on it and select New > String Record

A new window will pop up for the new record’s details. Select HttpRedirect from the Record Name or Identifier combobox and click OK.

You should now have a new, empty, string record sitting inside your facility9.html key.

Double click on the new, empty, record to bring up the HttpRedirect Properties window. In the Value Data text box, type ‘http://facility9.com,PERMANENT’, without the quotes (obviously). This will set up a permanent redirect in IIS from http://yourwebsite.com/facility9.html to http://facility9.com. Switch to the General tab and set the User Type to File. This forces IIS to respond to your HttpRedirect as if it were an actual file. If you don’t set this, you will get a 404 error.

You can find more details about the HttpRedirect Metabase Property (and other metabase properties) from the Windows Client Center of TechNet: http://technet.microsoft.com/en-us/library/cc757144.aspx.
