Forum Moderators: phranque
I've run into a little issue trying to get mod_rewrite to play nicely with a password-protected subdirectory I have set up.
In the root directory of my site, I have the following .htaccess file:
# DirectoryIndex index.php index.html
# Options +FollowSymLinks
# RewriteBase /relative/web/path/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
</IfModule>
...And here's the .htaccess file in the password protected directory of my site.
AuthUserFile "/home/path/.htpasswds/members/passwd"
AuthName "Members Only Section"
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>
Unfortunately, when I try to access the "members" section of my site, the rewrite is working so well that it just redirects to the index located in the root directory.
Any tips or solutions you can provide would be sincerely appreciated!
Welcome to WebmasterWorld!
A negative-match RewriteCond added to the beginning of the ruleset would do it:
RewriteCond %{REQUEST_URI} !^/members/
...
Jim
To confirm, here's what my root .htaccess file looks like now...
# DirectoryIndex index.php index.html
# Options +FollowSymLinks
# RewriteBase /relative/web/path/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/members/ [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
</IfModule>
Unfortunately, I'm still seeing the same behavior as before: the /members subdirectory is still being subjected to the rewrite...
Cache cleared but still the same behavior.
Is there a way to turn off Rewrite in the subdirectory I'm attempting to password-protect? I tried a simple Rewrite Off in there, but that didn't help either.
Or maybe instead of a catch-all sort of set up, perhaps I could specifically designate which get subjected to the rewrite rule?
FYI, this has to do with an installation of Textpattern on an Apache server.
<snip>
[edited by: jdMorgan at 1:31 am (utc) on Sep. 23, 2005]
[edit reason] Removed URLs per TOS. [/edit]