Computer Tips and Tricks
Get the latest posts via rss

Wednesday, 9 December 2009

Windows Server 2008 IIS7 HTTP Redirection

In IIS6 to redirect a virtual directory within a website to another URL, local or remote, was a nice and simple process. It was just a case of right clicking on the virtual directory, selecting properties and on the Directory Tab selecting “A Redirection to a URL” and entering the required address.

With the introduction of IIS7 in Windows Server 2008 this was published as an improved feature. So when asked to move a virtual directory, and forward all requests to the original address to the new URL I presumed this would be just as straight forward.

So first things first, HTTP Redirection is not included in the standard IIS7 setup, when you add it as a Role. So to start with using Server manager, add the Role Service to IIS (I will presume you know how to do this).

Once the Role Service has been added, go to Internet Information (IIS) Manager, when you click on the virtual directory that requires to be forwarded, you will see the HTTP Redirection in the Features View under IIS
When you double click HTTP redirect you are presented with the following

So, its now just a case of checking “Redirect requests to this Destination:” and entering the required URL of where you want the traffic to be redirected.

By default the Redirect behaviour boxes are unchecked. With the settings applied like so, all pages requested from the virtual directory will be redirected to the new URL. If either of the boxes are checked, the appropriate rule will apply.

Now there are 3 options in the Status Code;

  • Found (302)
  • Permanent (301)
  • Temporary (307)
We found that using the Permanent (301) gave the best results (i.e. it forwarded page requests)

So, although it looks a little more complicated in IIS7 than it did in IIS6 its still relatively straight forward, and works very well.

As a note we did find the following issue after using this. If you set up the HTTP Redirection on an existing folder or application, and then afterwards delete the folder contents, the redirection gets turned off. Took some head scratching for us to find the obvious, but once re-enabled all OK again.


Post a Comment