Monday, September 20, 2010

Simple HTTP Redirect with Querystring in IIS7

HTTP Redirect seems simple enough. Always was in IIS6 and in IIS7 there's even a button labeled HTTP Redirect that promises relative redirects.  It looks like it'll be as easy Apache finally.  That is until you try to redirect a querystring.  Then everything bombs.

Turns out it still is relatively easy, except you have to know that Microsoft changed $S$Q to $V$Q. Why? $Ss and $Gs I suspect.

And How.
In our example we'll redirect all pages under to
  1. Pick the virtual directory you want to redirect. e.g.
  2. Click HTTP Redirect under IIS in the IIS management console.
  3. In the HTTP Redirect Dialog:

    • Check Redirect requests to this destination
    • Enter your new path ending with $V$Q.  e.g.$V$Q
    • Counter-intuitively check Redirect all request to exact destination (instead of relative destination)
    • Choose the appropriate Status Code (Permanent or Temporary)
  4. Apply Changes and Test


Dell said...

Thank you - it took a long time to find this answer. I almost gave up.

dirq said...

Thanks! You've documented what Microsoft should have! :)

Alexander Undén said...

Thanks! Helped me out in a tricky one, keep up the good posts! :)

Chris Randle said...
This comment has been removed by the author.
Chris Randle said...

I did this this year but lost the code. I found it here and it helped me out too.