Random thoughts of wisdom - the personal blog of Michael Holm Andersen

301 Redirects on IIS7 – come again Microsoft!!

Creating a 301 Redirect in IIS7 is EVEN MORE CRAPPY than on IIS6 – I was going “nuts” trying to find out why my 301 Redirect didn’t work.

What I wanted to do (a pretty common scenario) was to redirect traffic from my URL without www to the version of my domain name – however this (one should think!) simple task is not easily done!! Here’s how to do it:

You have to create a new website (one could wonder why it’s not possible simply to add e.g. 301 Permanent headers to a host name and in this way quickly be able to add a list of URLs which would be 301 redirected) – when creating the website you HAVE to enter a Physical Path when creating the site. The wizard forces you to pick a path even if you plan to redirect the site to a URL.

The most obvious would be to pick the root folder of the site you plan on redirecting to, however this (why, Microsoft?) caused an error for both sites due to a continuous redirection. You have to create an empty directory for the site you want to redirect, which makes no sense at all (why does the directory matter when all I want to do is make a 301 permanent redirect).

This ought to be MUCH SIMPLER if you ask me!