Redirect IIS重定向规则不工作 `

Redirect IIS重定向规则不工作 `,redirect,iis,web-config,Redirect,Iis,Web Config,我有两个url,如www.mydomain/Directories/the和www.mydomain/Directories/the-hindu。但我只想重定向第一个网址而已。如果我把上面的代码两个网址重定向 我尝试了精确匹配,外卡也不起作用。我不想在我的主页上看到www.mydomain/Directories/the-indu `问题是您的regexp^目录/该与两个URL匹配: www.mydomain/Directories/the www.mydomain/Directories/t

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

我尝试了精确匹配,外卡也不起作用。我不想在我的主页上看到www.mydomain/Directories/the-indu


`

问题是您的regexp
^目录/该
与两个URL匹配:

  • www.mydomain/Directories/the
  • www.mydomain/Directories/the-indu
您需要将字符串结束条件添加到regexp。正确的规则应该是:

<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>`