【问题标题】:IIS rewrite with unusual ~ character in the URLIIS 在 URL 中使用不寻常的 ~ 字符重写
【发布时间】:2019-11-14 05:33:49
【问题描述】:

我的网址格式为:

https://www.example.com/aaa/bbb/product/~productId=abc123

我想重定向到:

https://www.example.com/product/abc123

我已经对此尝试了几种变体,但无法获取它(尽管在 IIS URL 重写正则表达式测试器中对此进行了测试)。

<rule name="Custom rule 12" stopProcessing="true">
    <match url="aaa/bbb/product/(.*)" />
    <conditions>
        <add input="{HTTP_URL}" pattern="~productId=(.*)$" />
    </conditions>
    <action type="Redirect" url="/product/{C:1}" appendQueryString="false" />
</rule>

【问题讨论】:

    标签: redirect iis url-rewriting iis-8 iis-8.5


    【解决方案1】:

    根据你的描述,我建议你可以尝试使用下面的url重写规则。

                <rule name="specialcharacter" stopProcessing="true">
                    <match url="aaa/bbb/product/~productId=(.*)" />
                    <action type="Redirect" url="https://www.example.com/product/{R:1}" />
                </rule>
    

    结果:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-04
      • 1970-01-01
      相关资源
      最近更新 更多