我需要重写url:
http://www.mydomain.com/test.aspx?pagename=quotes&companycode=324543
至
http://www.mydomain.com/test/quotes/324543
我正在使用IIS 7.5和VS 2008。
我需要在web.config中插入文本。
然后在web.config中的XMLpathsystem.webServer / rewrite / rules中安装URL重写
<rule name="Rule" stopProcessing="true"> <match url="test.aspx" /> <conditions> <add input="{QUERY_STRING}" pattern="pagename=([a-zA-Z0-9]+)&companycode=([0-9]+)" /> </conditions> <action type="Rewrite" url="test/{C:1}/{C:2}" appendQueryString="false" /> </rule>
如果您不需要查询string中的所有参数,则可以用它们的文字replace正则expression式和参数({C:1} / {C:2})。