6

I am trying to set up a rewrite rule in IIS7 to hide page extensions (.aspx) but also field and pass querystring parameters to the page.

For example, if the original URL is:

www.mysite.com/page.aspx?pid=a

how can I get it to rewrite to

www.mysite.com/page

but still pass the querystring value to the page?

2 Answers 2

5

If you are putting it into a web.config, You are looking for appendQueryString

<rule name="MyRule" stopProcessing="true">
   <match url="{your regex}" ignoreCase="false" />
   <action type="Rewrite" url="{your rewrite}" appendQueryString="true" />
</rule>

If you are doing it in IIS Manager, check the "Append query string" box.

2
  • 1
    I am getting the URL to rewrite without the .aspx extension but it still keeps the querystring parameters in the URL. So www.mysite.com/page.aspx?pid=a still shows as: www.mysite.com/page?pid=a but what i want is: www.mysite.com/page with the parameters still received by the page. Is this possible?
    – mitch
    Commented Jun 18, 2010 at 23:24
  • @mitch - No, I don't think so. Commented Jun 21, 2010 at 11:54
0

You might want to check this out: http://learn.iis.net/page.aspx/465/url-rewrite-module-configuration-reference/#Rules_Evaluation

But according to this article, in the Rewrite Action there is a 'appendQueryString' parameter which determines whether the query string is appended to the new URL. This should be on by default (again according to that article), so you shouldn't have to do anything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.