59

I have a url:

http://mywebsite.com/Account/?Number=25191108&Name=Something&Remote=False

which I would like to redirect to:

http://anotherwebsite.com/whatever/

and preserve the query string:

http://anotherwebsite.com/whatever/?Number=25191108&Name=Something&Remote=False

Does anyone have any ideas how to achieve this?

Tony L.
  • 17,638
  • 8
  • 69
  • 66
Sparkle
  • 2,459
  • 3
  • 18
  • 20

2 Answers2

116
  1. Go into the IIS site properties for the domain you're moving from. In the "Home Directory" tab, click the option "A redirection to a URL"
  2. In the Redirect to box, enter the domain you wish to move to (no trailing slash), plus $S$Q - for example, http://www.YourDomain.com$S$Q
  3. Next, check the options that state the client will be sent to "The exact URL entered above", and "A permanent redirection for this resource"
Sparkle
  • 2,459
  • 3
  • 18
  • 20
  • I found this which helped me: http://www.developerfusion.com/code/4678/permanent-301-redirect-with-querystring-in-iis/ so when I saw this SO question, I figured I'd upvote it here too in case I have to find it again in the future... – Allan Jan 11 '13 at 20:14
  • 12
    NOTE! $V$Q seems to be the new addition in IIS7+ (instead of $S$Q). S changed to V. Not sure why but anyway $V$Q works for me. – Max Nov 29 '13 at 11:58
  • 20
    reference on the wildcard values for HTTP Redirects in IIS: http://technet.microsoft.com/en-us/library/cc737576.aspx – ashtonium Apr 01 '14 at 18:18
  • This site does a good job of explaining how it works in IIS 7 https://blogs.iis.net/ksingla/client-side-redirection-using-httpredirection-module – N1njaB0b Oct 19 '17 at 14:58
18

You can see the complete solution here:

enter image description here

Tried it in IIS 10 and works as expected.

The status code can be anything you prefer. 301 for permanent redirect and 302/307 for temporary redirect.

Nikolay Kostov
  • 16,433
  • 23
  • 85
  • 123