简体   繁体   English

IIS7重定向使用重写模块问题

[英]IIS7 Redirect using Rewrite module Issue

I have changed domains and am trying to redirect all requests except for a few URLs. 我更改了域名,并尝试重定向所有请求,除了一些URL。 However I can't seem to get it to behave as expected and everything gets redirected - I'm sure it must be something small - any help would be appreciated! 但是我似乎无法使其表现出预期的效果,并且一切都被重定向了-我确定它一定很小-任何帮助将不胜感激!

I need for all URLs to be redirected, except anything with the path "auth" or "ipet", as well as file.aspx including its querystring. 我需要重定向所有URL,但路径为“ auth”或“ ipet”的文件以及包括其querystring的file.aspx除外。 The rest of olddomain.com should all redirect to newdomain.com. olddomain.com的其余部分应全部重定向到newdomain.com。

<rule name="Redirect" enabled="true" stopProcessing="true">
<match url=".*" />
<conditions trackAllCaptures="false" logicalGrouping="MatchAll">
    <add input="{HTTP_HOST}" pattern="www\.olddomain\.com" />
    <add input="{URL}" pattern="^file.aspx$" negate="true" />
    <add input="{URL}" pattern="^auth/?" negate="true" />
    <add input="{URL}" pattern="^ipet/?" negate="true" />
</conditions>
    <action type="Redirect" url="http://newdomain.com" />
</rule>

Use the following.. without ^ : 使用以下..不带^

<add input="{URL}" pattern=".*?auth/?" negate="true" />
<add input="{URL}" pattern=".*?ipet/?" negate="true" />

logicalGrouping="MatchAll" indicates all conditions must be true to do the redirect. logicalGrouping =“ MatchAll”表示所有条件都必须为真才能进行重定向。 Change logicalGrouping="MatchAny" and change match url. 更改logicalGrouping =“ MatchAny”并更改匹配网址。

<rule name="Redirect" enabled="true" stopProcessing="true">
<match url="www\.olddomain\.com" />
<conditions trackAllCaptures="false" logicalGrouping="MatchAny">
    <add input="{REQUEST_URI}" pattern=".*?file.aspx$" negate="true" />
    <add input="{REQUEST_URI}" pattern=".*?auth/?" negate="true" />
    <add input="{REQUEST_URI}" pattern=".*?ipet/?" negate="true" />
</conditions>
    <action type="Redirect" url="http://newdomain.com" />
</rule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM