问题
I have a URL in the format:
https://www.example.com/aaa/bbb/product/~productId=abc123
Which I would like to redirect to:
https://www.example.com/product/abc123
I have tried a couple of variations on this and just cannot get this to pick it up (despite testing this in the IIS URL rewrite regex tester).
<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>
回答1:
According to your description, I suggest you could try to use below url rewrite rule.
<rule name="specialcharacter" stopProcessing="true">
<match url="aaa/bbb/product/~productId=(.*)" />
<action type="Redirect" url="https://www.example.com/product/{R:1}" />
</rule>
Result:
来源:https://stackoverflow.com/questions/56871612/iis-rewrite-with-unusual-character-in-the-url