views:

1332

answers:

3

I am running the free version of Helicon ISAPI Rewrite on IIS and have several sites running through the same set of rewrite rules. Up 'til now this has been fine as all the rules have applied to all the sites. I have recently added a new site which I don't want to run through all the rules. Is there any way to make requests to this site break out of the rule set after it's executed its own rules.

I've tried the following with no luck; all requests to mysite.com result in a 404. I guess what I'm looking for is a rule that does nothing and is marked as the last rule to execute [L].

## New site rule for mysite.com only
RewriteCond  Host:  (?:www\.)?mysite\.com
RewriteRule  /content([\w/]*)   /content.aspx?page=$1 [L]

## Break out of processing for all other requests to mysite.com
RewriteCond  Host:  (?:www\.)?mysite\.com
RewriteRule (.*) - [L]

## Rules for all other sites
RewriteRule ^/([^\.\?]+)/?(\?.*)?$ /$1.aspx$2 [L]
...
+1  A: 

Rewrite it to itself?

RewriteCond  Host:  (?:www\.)?mysite\.com
RewriteRule ^(.*)$ $1 [QSA,L]
MrZebra
Won't this rule cause a loop of requests?
Rob Bell
Hmm I was hoping it wouldn't cause a loop because it's just a rewrite and not a redirect... but I admit that I haven't tried it
MrZebra
I'm pretty sure a rewrite will cause a second request. The rule will work as I think there is a limit to the number of repeating requests, but I'm not sure what effect this will have on load times, server load etc.
Rob Bell
A: 

I've done something similar, to stop mod_rewrite on a WebDAV folder:

# stop processing if we're in the webdav folder
RewriteCond %{REQUEST_URI} ^/webdav [NC]
RewriteRule .* - [L]

That should work for your purposes too. If not or if you are interested in additional references, see this previous question: How do I ignore a directory in mod_rewrite?

Jay
A: 

I don't know ISAPI Rewrite syntax, but on IIRF, the "break out" rule is like this:

## Break out of processing for all other requests to mysite.com
RewriteCond %{SERVER_NAME}  ^(?:www\.)?mysite\.com$
RewriteRule (.*) - [L]

or

## Break out of processing for all other requests to mysite.com
RewriteCond %{HTTP_HOST}  ^(?:www\.)?mysite\.com$
RewriteRule (.*) - [L]

In each case the rule says "don't rewrite (and don't process any more rules)" and it applies when the hostname used is mysite.com or www.mysite.com. The [L] flag is the part that says "don't process any more rules" and the - replacement is the part that says "don't rewrite".

Cheeso