IIS 在 URL 中用不寻常的 ~ 字符重写
IIS rewrite with unusual ~ character in the URL
我有一个 URL 格式:
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>
根据你的描述,我建议你可以尝试使用下面的url重写规则。
<rule name="specialcharacter" stopProcessing="true">
<match url="aaa/bbb/product/~productId=(.*)" />
<action type="Redirect" url="https://www.example.com/product/{R:1}" />
</rule>
结果:
我有一个 URL 格式:
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>
根据你的描述,我建议你可以尝试使用下面的url重写规则。
<rule name="specialcharacter" stopProcessing="true">
<match url="aaa/bbb/product/~productId=(.*)" />
<action type="Redirect" url="https://www.example.com/product/{R:1}" />
</rule>
结果: