views:

54

answers:

1

I have an Apache .htaccess file in the parent directory to directory this .htaccess file is currently located. This works perfectly redirecting all requests as required. However, I would like it so in this directory, if the request is for a valid file (and NOT a directory), ignore the main rewrite rule.

Currently, the following turns off the rewrite for directories as well, and I can't figure out why.

<IfModule mod_rewrite.c>
 Options +FollowSymLinks
 Options +Indexes
 RewriteEngine On
 RewriteBase /
 RewriteCond %{REQUEST_URI} !-d
 RewriteCond %{REQUEST_URI} -f
 RewriteRule . - [L]
</IfModule>

Thanks to anyone who contributes.

+1  A: 

Try REQUEST_FILENAME instead of REQUEST_URI:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [L]

REQUEST_URI does only contain the URI path but Apache needs an absolute file system path to test agains -d and -f. And REQUEST_FILENAME holds the absolute file system path corresponding to the current requested URI.

Gumbo
No such luck I'm afraid. Good idea though, that should work in theory. I blame my hosting providers!
mynameiszanders
@mynameiszanders: Try to investigate what values `REQUEST_FILENAME` contains.
Gumbo