IIS 301s

We don’t use IIS very much, but a third party application that we are integrating into the corporate website runs on IIS, and today I had a very pressing need to add a redirect to one of the default application pages to one of our corporate site pages.

I discovered 2 very good solutions:

  • Add the following code to the top of the file you wish to redirect:
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location", "http://edgehill.ac.uk/rosetheatre/whatson/"

    This is quick and nasty way to redirect a page if you don’t have admin rights to your IIS server.

  • By far the best way is, if you have access to IIS admin, is to follow the following steps:
    1. Browse the website you want to do the redirect for.
    2. In the right pane, right click on the file you want to redirect, and click “Properties”
    3. Under the “File” tab, hit the radio selection “A redirection to a URL”
    4. Put the target in the “Redirect to” textarea.
    5. Make sure “The exact URL entered above” and “A permanent redirection for this resource” are both checked

Both of these solutions worked for me.