URL重写多个排除

时间:2017-07-13 12:02:43

标签: iis url-rewrite-module

我尝试编写一个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>

任何帮助表示赞赏!

1 个答案:

答案 0 :(得分: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>