Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -d
RewriteRule ^(.+)$  $1 [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.