Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.)

share|improve this question
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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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