简体   繁体   中英

IIS7 Redirect using Rewrite module Issue

I have changed domains and am trying to redirect all requests except for a few URLs. 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. The rest of olddomain.com should all redirect to 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. Change logicalGrouping="MatchAny" and change match url.

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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