Asp – Weird IIS7 http redirection behavior

asp.nethttpiis-7

I have a web server running Windows Server 2008 with IIS7. I have a bunch of websites which are all bound to the same IP address, but with different host header values. Most of the host headers are something like www.sitename.com.

I also have a corresponding website entry for each which listens for the host "sitename.com" and does a redirect to "www.sitename.com" within IIS7 (to cater for non-www requests). Now this is all pretty straight forward, but I've noticed the when setting up the Http Redirection, some wierd things happen:

Firstly, the "redirect" website entries must be pointed at a different physical directory than the site it's trying to redirect to, otherwise the redirection settings get set for both sites at once.

Secondly, sometimes whilst setting up Http Redirection on an individual site, Http Redirection gets set at a server level, and all sites start redirecting to that one URL.

How does this happen? Under what circumstances could setting Http Redirection on an individual site affect all sites? This is scary!!!

Best Answer

You need to point each of the websites to different physical location so that Http Redirection module can make a webconfig file for each of them.