Within an application that heavily depends on .htaccess RewriteRules because of its PrettyURLs (CakePHP during my situation), how do you properly setup directives to exclude certain sites out of this spinning? I.e.:


Automatically every request to /appRoot/* has been rewritten to become acquired by application/webroot/index.php, where it's being analysed and corresponding controller actions are now being invoked. This is accomplished by these directives inshtaccess:

RewriteBase /appRoot

RewriteRule ^$ application/webroot/ [L]
RewriteRule (.*) application/webroot/$1 [L]

I would now like to exclude a couple of sites like static/ out of this spinning. I attempted with this particular before the wedding cake RewriteRules:

RewriteCond $1 ^(staticotherDir).*$ [NC]
RewriteRule (.*) - [L]

It really works in to date that demands are no more rewritten, however all demands are now being missed, even legitimate Cake demands that ought to not match ^(staticotherDir).*$.

I attempted several versions of those rules but can't get results the way in which I would like.

For everyone attempting to debug .htaccess directives, you might like to do this:

RewriteCond    % (.*)
RewriteRule    ^(.*)$ htaccess.php?ruleMatch=$1&condMatch=%1 [L]

This redirects every request to become processed by htaccess.php, affixing the designs matched up by RewriteRule and RewriteCond as GET parameters. Within the php file you can just echo these parameters and also the atmosphere variables (REDIRECT_QUERY_STRING for instance) to obtain some inside into what's really being matched up because of your rules.

<h1>Matched by .* ($_GET):</h1>
<pre><?php print_r($_GET) ?></pre>
<pre><?php print_r($_SERVER) ?></pre>

(substitute by programming language of preference)

Still attempting to figure this issue out...

And also the correct answer iiiiis...

RewriteRule   ^(abunchofoldsites).* - [NC,L]

# other demands is going to be submitted to Cake
RewriteRule   ^$   application/webroot/   [L]
RewriteRule   (.*) application/webroot/$1 [L]

I still do not get why the index.php file within the root directory was known as initially despite these directives in position. It's now situated in


and handled through Cake too. With this particular in position now, I guess this could have labored too (slightly changed version of Mike's suggestion, untested):

RewriteCond $1      !^(abunchofoldsites).*$ [NC]
RewriteRule ^(.*)$  app/webroot/$1 [L]

Thank you for playing everyone. )

Take away the [L] in the previous rules:

RewriteBase /appRoot

RewriteRule ^$ application/webroot/ &nbsp &nbsp
RewriteRule (.*) application/webroot/$1

[L] means "Stop the spinning process here and do not apply anymore spinning rules."

Would you not apply the problem towards the following rules, however with negation, as with (with a few variation thereof, I am much less proficient at recalling .htaccess rules, therefore the flags may be wrong):

RewriteCond $1 !^(staticotherDir).*$ [NC]
RewriteRule ^$ application/webroot/ [L]

RewriteCond $1 !^(staticotherDir).*$ [NC]
RewriteRule ^$ application/webroot/$1 [L]