IIS redirect preserve QueryString?

IisIis 7Iis 6

Iis Problem Overview


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?

Iis Solutions


Solution 1 - Iis

  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"

Solution 2 - Iis

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSparkleView Question on Stackoverflow
Solution 1 - IisSparkleView Answer on Stackoverflow
Solution 2 - IisNikolay KostovView Answer on Stackoverflow