Iis Url重写:重定向传递查询参数

Iis Url重写:重定向传递查询参数,iis,url-rewriting,iis-7.5,Iis,Url Rewriting,Iis 7.5,使用IIS 7.5,如何重定向 http://localhost/en/test?id=tool-37 到 我写了这个规则,但它不起作用 <rule name="Tool-Diseases" stopProcessing="true"> <match url="(.+)/test.+id=([0-9]+)" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />

使用IIS 7.5,如何重定向

http://localhost/en/test?id=tool-37

我写了这个规则,但它不起作用

<rule name="Tool-Diseases" stopProcessing="true">
    <match url="(.+)/test.+id=([0-9]+)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
    <action type="Redirect" url="{R:1}/tool/{R:2}" appendQueryString="true" />
</rule>


谢谢

URL和查询字符串在IIS重写模块中分别处理

例如,如果请求此URL:,并且在站点级别定义了重写规则,则:

  • 规则模式获取URL字符串content/default.aspx作为输入
  • QUERY_STRING服务器变量包含tabid=2和subtabid=3
  • HTTP_主机服务器变量包含www.mysite.com
  • 服务器端口服务器变量包含80
  • SERVER\u PORT\u SECURE SERVER变量包含0,HTTPS包含OFF
  • 请求URI服务器变量包含/default.aspx?tabid=2&subtabid=3
您可以在IIS重写设置的“服务器变量”部分输入正则表达式以匹配查询字符串

<rule name="Tool-Diseases" stopProcessing="true">
    <match url="(.+)/test.+id=([0-9]+)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
    <action type="Redirect" url="{R:1}/tool/{R:2}" appendQueryString="true" />
</rule>