Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to rewrite the URL:

http://www.mydomain.com/test.aspx?pagename=quotes&companycode=324543

To

http://www.mydomain.com/test/quotes/324543

I am Using IIS 7.5 and VS 2008.

I need the text to insert in web.config.

share|improve this question

1 Answer 1

Install URL Rewriting then inside web.config at the XML path system.webServer/rewrite/rules

<rule name="Rule" stopProcessing="true">
  <match url="test.aspx" />
  <conditions>
    <add input="{QUERY_STRING}" pattern="pagename=([a-zA-Z0-9]+)&amp;companycode=([0-9]+)" />
    </conditions>
  <action type="Rewrite" url="test/{C:1}/{C:2}" appendQueryString="false" />
</rule>

If you don't need all parameters in the query string then you can replace the regex and parameters ({C:1}/{C:2}) with their literals.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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