IIS7 Url Rewrite – Can I use stopProcessing=”false” with a Redirect Rule

iis-7url-rewriting

I wish to canonicalize a domain name, from bar.example.com to www.example.com (well anything that's not www.example.com). Site runs IIS7.

The problem is that certain URLs were of the form http://bar.example.com/asp/oldpage.asp?query=awesome, and have specific URL rewrite rules already in place that redirect to http://www.example.com/newpage/awesome

I want to write a rule that catches the other rules.

HERE'S THE CATCH: I have a lot of rules, and want to put this rule in the root of the site, but have additional rewrite/redirect rules in sub-folders, so I want to defer the 301 from happening until all the rules have been run.

Is this possible? Rewrites have an option to defer (stopProcessing="false") but this doesn't seem to be an option for Redirects.

Am I SOL here?

Best Answer

Unfortunately, I can confirm that the deferred processing (stopProcessing="false") works with rewrite actions only and is ignored by the redirect ones.

Should the number of matches having been small - but it is not, according to your question - I would have suggested you to combine them using a regex alternation. For example:

First match: ^first/a$
Second match: ^second/b$

Combined match: ^(first/a|second/b)$

Leading to something like:

<rule name="MyCombinedRule">
    <match url="^(first/a|second/b)$" />
    <action type="Redirect" url="http://www.example.com/third/c" />
</rule>