Reputation: 1595
I have the existing rule as xml that will rewrite or redirect any request to a specific url to its domain. It won't let any outbound request go out of the domain.
I want to add an EXCEPTION to only one url (say abc.com). How to add an exception to a particular request?
(please donot provide anything like global.asax because IIS is not working with ASP.NET application but with some other application).
current rule:
<rewrite>
<rules>
<rule name="topcontent">
<match-url=".*">
<action type="rewrite" url="mysite.com/{R:0}"/>
</match-url>
</rule>
</rules>
</rewrite>
If any inbound request comes it rewrites the url to mysite.com. I need to add an exception to say abc.com/...... How to do this?
Upvotes: 2
Views: 1395
Reputation: 681
you can use below code:
<rule name="special" enabled="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll" >
<add input="{HTTP_HOST}" pattern="^(www\.)?abc\.com$" negate="true" />
</conditions>
<action type="Redirect" url="http://mysite.com/{R:0}"/>
</rule>
a condition has been added to the rule, so if it does not come true, then the action will be executed (negate="true"
)
it will check the http://{HTTP_HOST}/url
and if it does not match abc.com or www.abc.com which is exception here, then it will go for the action.
also I think that you may use Redirect
here instead of Rewrite
Upvotes: 0
Reputation: 1988
Create another rule above the topcontent
rule:
<rule name="special">
<match-url="abc.com">
<action type="rewrite" url="mysite.com/specialPage.htm"/>
</match-url>
</rule>
Here is a similar question: IIS URL rewrite exception
Upvotes: 2
Reputation: 7990
Go into IIS Manager > [your site] > Url Rewrite.
Add a new rule before this one that matches abc.com and check "Stop processing of subsequent rules".
Upvotes: 0