blog.mha.dk
The on-line blog of Michael Holm Andersen

301 Redirects on IIS7 – come again Microsoft!!

Friday, 10 September 2010 14:15 by mha

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 www.somethinggoeshere.dk 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!

Comments

September 10. 2010 17:40

Redirection shouldn't really be set up as part of the sites basic configuration if you ask me.

http://www.iis.net/download/URLRewrite would be a much nicer way to to and still keep it in configuration with something like this in system.webServer


<rewrite>
      <rules>
        <rule name="wwwredirect" stopprocessing="true">
          <match url=".*">
          <conditions>
            <add input="{HTTP_HOST}" pattern="^somethinggoeshere.com$">
          </add></conditions>
          <action type="Redirect" url="http://www.somethinggoeshere.com/{R:0}" redirecttype="Permanent">
        </action></match></rule>
      </rules>
    </rewrite>

Jakob Andersen

September 21. 2010 10:57

Nice information, many thanks to the author. It is incomprehensible to me now, but in general, the usefulness and significance is overwhelming. Thanks again and good luck!

Capodanno roma

September 21. 2010 11:01

i am really appreciating,woow very informative.....great job thank's...!

Traslochi

Comments are closed