我需要从example.com/landing重定向到example.com/blog/info/landing。我在web.config中写了一个规则
<rule name="Atlanta redirect" stopProcessing="true">
<match url="landing" />
<action type="Redirect" url="https://www.example.com/blog/info/landing" redirectType="Permanent" />
</rule>
但是如果url与“着陆”字词匹配,那么它也会重定向到example.com/blog/info/landing。
例如正确的重定向:example.com/landing-> example.com/blog/info/landing
错误的重定向example.com/somepage/1/着陆-> example.com/blog/info/着陆
使用与/landing
完全匹配的正则表达式:
<match url="^landing$" />
(IIS在进行正则表达式匹配时会删除前导/
)>>
[^
和$
符号是分别与字符串的开头和结尾匹配的正则表达式锚。