Reputation: 3695
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]
...
Upvotes: 6
Views: 13243
Reputation: 10396
RewriteRule ^ - [END]
.
would be incorrect, since it requires at least 1 char.*
could be less efficient IMHOUpvotes: 5
Reputation: 192507
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".
Upvotes: 1
Reputation: 42652
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?
Upvotes: 11
Reputation: 11492
Rewrite it to itself?
RewriteCond Host: (?:www\.)?mysite\.com
RewriteRule ^(.*)$ $1 [QSA,L]
Upvotes: 2