【问题标题】:IIS redirect rule not workingIIS 重定向规则不起作用
【发布时间】:2018-04-05 19:41:56
【问题描述】:
<rule name="Directories The" stopProcessing="true">
    <match url="^Directories/The" />
    <action type="Redirect" url="/" />
</rule>`

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

我尝试了完全匹配和通配符也不起作用。我不希望 www.mydomain/Directories/the-hindu 进入我的主页

`

【问题讨论】:

标签: redirect iis web-config


【解决方案1】:

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

  • www.mydomain/Directories/the
  • www.mydomain/Directories/the-hindu

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

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

而且这条规则只会匹配www.mydomain/Directories/the

【讨论】:

    猜你喜欢
    • 2017-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-10
    • 2016-02-25
    • 2018-08-25
    相关资源
    最近更新 更多