URL 重写多个排除
URL rewrite multiple excludes
我正在尝试编写一个 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>
感谢任何帮助!
规则中的逻辑分组应为 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>
我正在尝试编写一个 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>
感谢任何帮助!
规则中的逻辑分组应为 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>