我有一项业务要求,将浏览尝试仅重定向到“首页URL”到另一个站点,但是不应重定向深层URL。
例如mydomain.com/ abc 应该转到mydomain.com/XYZ
但是
mydomain.com/ abc /deep/page.html等应保持不变。
根据Lex li的建议,添加了以下重写规则,它在IIS中测试为肯定,但在实际浏览过程中未重定向:
<rules>
<rule name="iamNoSlash" stopProcessing="true">
<match url="abc$" />
<action type="Redirect" url="mydomain.com/xyz" appendQueryString="false" />
</rule>
<rule name="iamWithSlash">
<match url="abc/$" />
<action type="Redirect" url="mydomain.com/xyz" appendQueryString="false" />
</rule>
</rules>