Directories to parameters with IIS 6 and wildcard redirection

Some parameters have been changed to protect the innocent. 

This could be old news, and since I'm talking about IIS 6, I know it is. But, I just discovered the other day how to pass parameters to a file using IIS 6, a virtual directory, and a URL that contains directories below the virtual directory.

So, at work I had a horrible URL like the following (ignore the invalid space):

/filename.cfm?parameterA=valueA&parameterB=valueB &issuemonth=4&issueyear=2008&groupname=publ

What I wanted to do was allow someone to use a URL like this to get to that page:

/enews/publ/2008/4/
 - or -
/enews/publ/2008/4

Luckily, after a lucky Google search, I found a Microsoft TechNet on this very issue, in the Server 2003 Redirect Reference (IIS 6.0).

The solution was to create a virtual directory called enews, and configure it to redirect to the exact URL entered:

;////; /filename.cfm?parameterA=valueA&parameterB=valueB&issuemonth=$2&issueyear=$1&groupname=$0;///*; /filename.cfm?parameterA=valueA&parameterB=valueB&issuemonth=$2&issueyear=$1&groupname=$0

Basically the second and third, semi-colon-delimited, strings handle the first URL (trailing slash) while the fourth and fifth handle the second.

One thing that isn't covered is if they don't pass a 'month'. However, I'd assume that an additional 'block' could be setup to handle this, as well as the case where there's only a group name.

The disappointing thing is that this doesn't allow for too much in the way of wildcards - you can manually add text, or use a * for a wildcard - nothing fancy with switches or anything. But … that's okay.

The TechNet article covers a number of other things, so … definitely give it a look.

The more I use Microsoft products, the more impressed I am with the resources they make available online.