So, I'm trying to redirect any pages to a file, but avoid redirecting anything thats an existing file or directory.

RewriteEngine On
RewriteRule ^(.+)$  $1 [L]
RewriteRule ^(.+)$  /index.php?page=$1 [QSA]

However, any directories still get redirected (existing files are fine and can be located.)

  • are you asking how to redirect any file (but not directory) requests that don't exist? – DTest Jan 6 '11 at 14:37

You're using REQUEST_FILENAME to mean REQUEST_URI, and while that is documented to work in some cases (like when used on a vhost), I have a feeling that in this case it's already determined into the final name. See if RewriteCond %{REQUEST_FILENAME} -d makes a difference, or just always use REQUEST_URI.

If not, well, one option is to rewrite to add index.htm/html/php/pl etc to the end, test each for existence and finalize the rule if so, otherwise go to the last step? That's all that I can think of off the top of my head.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.