Home > DeveloperSection > Forums > IIS Web.config 301 Redirect in ASP.NET including Parameter
Ankit Singh

Total Post:341

Posted on    November-10-2014 11:29 PM

 ASP.Net Web Config  Redirect  Url Rewriting 

 1 Reply(s)
 1271  View(s)
Rate this:

I'm looking into using 301 redirects having noticed a bunch of hits on my domain on Google Analytics to .asp pages which not longer exist having moved everything over to a .NET setup.

Having spent a bit of time Googling, I have been able to add the following code to my web.config.

<location path="products.aspx">


     <httpRedirect enabled="true" destination="https://www.mindstick.com/products.aspx" httpResponseStatus="Permanent" />



This is fine and moves everything from products.asp to pproducts.aspx but it does not preserve the querystring, which is essential to make any sense, ie products.aspx?id=789 

Tanuj Kumar

Total Post:134

Posted on    November-11-2014 1:53 AM

You have to add $Q to the destination url to preserve the querystring. So in your case it should look like this:

<location path="products.asp">


     <httpRedirect enabled="true" destination="https://www.mindstick.com/products.aspx$Q" httpResponseStatus="Permanent" />



Don't want to miss updates? Please click the below button!

Follow MindStick