IIS 重定向规则不起作用
IIS redirect rule not working
<rule name="Directories The" stopProcessing="true">
<match url="^Directories/The" />
<action type="Redirect" url="/" />
</rule>`
我有两个 url 这样的 www.mydomain/Directories/the 和 www.mydomain/Directories/the-hindu。但我只想先重定向 url 而已。如果我把代码放在上面,两个 url 正在重定向。
我试过完全匹配和通配符也不起作用。我不想让 www.mydomain/Directories/the-hindu 进入我的主页
`
问题是您的正则表达式 ^Directories/The
与两个网址匹配:
- www.mydomain/Directories/the
- www.mydomain/Directories/the-印度教
您需要将字符串结束条件添加到您的正则表达式中。正确的规则应该是:
<rule name="Directories The" stopProcessing="true">
<match url="^Directories/The$" />
<action type="Redirect" url="/" />
</rule>`
并且此规则将仅匹配 www.mydomain/Directories/the
<rule name="Directories The" stopProcessing="true">
<match url="^Directories/The" />
<action type="Redirect" url="/" />
</rule>`
我有两个 url 这样的 www.mydomain/Directories/the 和 www.mydomain/Directories/the-hindu。但我只想先重定向 url 而已。如果我把代码放在上面,两个 url 正在重定向。
我试过完全匹配和通配符也不起作用。我不想让 www.mydomain/Directories/the-hindu 进入我的主页
`
问题是您的正则表达式 ^Directories/The
与两个网址匹配:
- www.mydomain/Directories/the
- www.mydomain/Directories/the-印度教
您需要将字符串结束条件添加到您的正则表达式中。正确的规则应该是:
<rule name="Directories The" stopProcessing="true">
<match url="^Directories/The$" />
<action type="Redirect" url="/" />
</rule>`
并且此规则将仅匹配 www.mydomain/Directories/the