【问题标题】:URL rewrite multiple excludesURL 重写多个排除
【发布时间】:2018-01-06 02:21:06
【问题描述】:

我正在尝试编写一个 IIS Url 重写规则来重定向除两个之外的所有请求,但我想不通。

我想要完成的事情: http://server/healthcheck.aspx --> not redirected http://server/idsrv2/2/stuff --> not redirected http://server/stuffstuff --> redirect to http://server/idsrv2/stuffstuff

这是我目前的规则,但它并没有生效: <rule name="Redirect everything to idsrv/2" patternSyntax="Wildcard" stopProcessing="true"> <match url="^$" /> <conditions logicalGrouping="MatchAny"> <add input="{REQUEST_URI}" pattern="^(.*)healthcheck" negate="true"/> <add input="{REQUEST_URI}" pattern="^(.*)idsrv2" negate="true" /> </conditions> <action type="Redirect" url="idsrv2{R:1}" appendQueryString="true"/> </rule>

任何帮助表示赞赏!

【问题讨论】:

    标签: iis url-rewrite-module


    【解决方案1】:

    您的规则中的逻辑分组应为MatchAll。我已经改变了你的规则,这应该适用于你的情况:

    <rule name="Redirect everything to idsrv/2" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_URI}" pattern="^/healthcheck" negate="true"/>
            <add input="{REQUEST_URI}" pattern="^/idsrv2" negate="true" />
        </conditions>
        <action type="Redirect" url="idsrv2/{R:0}" appendQueryString="true" />
    </rule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多