tags:

views:

126

answers:

2

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?

A: 

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.

Coding Gorilla
A: 

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.

Eric Petroelje
I am getting the URL to rewrite without the .aspx extension but it still keeps the querystring parameters in the URL. Sowww.mysite.com/page.aspx?pid=astill shows as:www.mysite.com/page?pid=abut what i want is:www.mysite.com/pagewith the parameters still received by the page.Is this possible?
mitch
@mitch - No, I don't think so.
Eric Petroelje