IIS重定向规则无效

时间:2018-04-05 19:41:56

标签: redirect iis web-config

<rule name="Directories The" stopProcessing="true">
    <match url="^Directories/The" />
    <action type="Redirect" url="/" />
</rule>`

我有两个这样的网址www.mydomain / Directories /和www.mydomain / Directories / the-hindu。但我只想重定向第一个网址。如果我把上面的代码放在两个网址重定向。

我试过完全匹配,外卡也无法正常工作。我不希望www.mydomain / Directories / the-hindu到我的主页

`

1 个答案:

答案 0 :(得分:1)

问题是您的正则表达式^Directories/The与两个网址匹配:

  • www.mydomain /目录/的
  • www.mydomain /目录/的-印度

您需要将字符串条件的结尾添加到正则表达式中。正确的规则应该是:

<rule name="Directories The" stopProcessing="true">
    <match url="^Directories/The$" />
    <action type="Redirect" url="/" />
</rule>`

此规则仅匹配www.mydomain/Directories/the

相关问题