Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS7 Url Rewrite - Can I use stopProcessing="false" with a Redirect Rule?

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?

like image 923
Broam Avatar asked Dec 08 '11 17:12

Broam


People also ask

What is the difference between URL Rewrite and redirect?

Simply put, a redirect is a client-side request to have the web browser go to another URL. This means that the URL that you see in the browser will update to the new URL. A rewrite is a server-side rewrite of the URL before it's fully processed by IIS.


1 Answers

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>
like image 136
Efran Cobisi Avatar answered Oct 23 '22 13:10

Efran Cobisi