【问题标题】:Url rewriting: Redirection passing query parameterUrl重写:重定向传递查询参数
【发布时间】:2012-06-15 21:07:02
【问题描述】:

使用 IIS 7.5 如何重定向

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

http://localhost/en/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>

谢谢

【问题讨论】:

    标签: iis url-rewriting iis-7.5


    【解决方案1】:

    URL 和 QueryString 在 IIS 重写模块中单独处理。

    例如,如果对该 URL 发出请求:http://www.mysite.com/content/default.aspx?tabid=2&subtabid=3,并且在站点级别定义了重写规则,则:

    • 规则模式获取 URL 字符串 content/default.aspx 作为输入
    • QUERY_STRING 服务器变量包含 tabid=2&subtabid=3。
    • HTTP_HOST 服务器变量包含 www.mysite.com。
    • SERVER_PORT 服务器变量包含 80。
    • SERVER_PORT_SECURE 服务器变量包含 0,HTTPS 包含 OFF。
    • REQUEST_URI 服务器变量包含 /default.aspx?tabid=2&subtabid=3

    您可以在 IIS 重写设置的“服务器变量”部分输入正则表达式以匹配您的查询字符串。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-29
      • 2021-04-07
      相关资源
      最近更新 更多