Forum Moderators: phranque
RewriteEngine on
RewriteCond /exampledirectory/%{REQUEST_FILENAME} -f
RewriteRule ^(.+) /exampledirectory/$1 [L]
Then when I try to access my site at example.com/about.php for example, and example.com/exampledirectory/about.php exists, I get a 404 error. When I comment out the RewriteCond it works perfectly though.
What might be causing this problem? Thanks!
Looking at what you've got, and using an typical example value for DOCUMENT_ROOT of "/users/example/www/html" and a requested URL of "example.com/about.php", the path examined by your RewriteCond would be "/exampledirectory//users/example/www/html/about.php"
You might try using
RewriteCond %{DOCUMENT_ROOT}/exampledirectory%{REQUEST_URI}
instead. If necessary, you could make a test rule to 'expose' your values in your browser's address bar, so you can see them. For example:
RewriteCond $1 !^exampledirectory/
RewriteRule ^(.+)$ /exampledirectory/$1?the-tested-filepath-was=/exampledirectory/%{REQUEST_FILENAME} [R=302,L]
Jim