How to exclude a sub-folder from HTaccess RewriteRule

Posted by amb9800 on Server Fault See other posts from Server Fault or by amb9800
Published on 2010-07-06T15:31:19Z Indexed on 2012/03/30 23:32 UTC
Read the original article Hit count: 245

I have WordPress installed in my root directory, for which a RewriteRule is in place.

I need to password-protect a subfolder ("blue"), so I set the htaccess in that folder as such.

Problem is that the root htaccess RewriteRule is applying to "blue" and thus I get a 404 in the main WordPress site (instead of opening the password dialog for the subfolder).

Here's the root htaccess:

RewriteEngine on

<Files 403.shtml>
order allow,deny
allow from all
</Files>     

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

I tried inserting this as the second line, to no avail:

RewriteRule ^(blue)($|/) - [L]

Also tried inserting this before the index.php RewriteRule:

RewriteCond %{REQUEST_URI} !^/blue/

That didn't work either.

Also inserted this into the subfolder's htaccess, which didn't work either:

<IfModule mod_rewrite.c> RewriteEngine off </IfModule>

Any ideas?

© Server Fault or respective owner

Related posts about apache2

Related posts about rewriterule