rewrite rule

StewSupport
StewSupport used Ask the Experts™
on
the code below will hide aspx extension. but now if my page is http://www.test.com/test.aspx?id=1&name=test the page stop working. Can someone help me with this? how do i make it so that it will do both hide .aspx extension and replace ?id=1&name=test to /1/test. i want it to be dynamic i don't want to have to list out all of the ids and name in my rule. please help. thank you in advance



<rewrite>
      <rules>
        <rule name="RemoveASPX" enabled="true" stopProcessing="true">
          <match url="(.*)\.aspx" />
          <action type="Redirect" url="{R:1}" />
        </rule>
        <rule name="AddASPX" enabled="true">
          <match url=".*" negate="false" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
          </conditions>
          <action type="Rewrite" url="{R:0}.aspx" />
        </rule>
      </rules>
    </rewrite>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
i found those links too but not really doing it. here is what i added and it doesn't seem to be working
<rule name="Query String Rewrite">  
	  		<match url="test\test.aspx$" />  
		  	<conditions>  
				<add input="{QUERY_STRING}" pattern="p1=(\d+)" />  
		  	</conditions>  
	  		<action type="rewrite" url="test/test.aspx?id={C:1}" appendQueryString="false"/>

Open in new window


remember before this rule is a rule to remove .aspx extension too

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial