0

I have the following mod_rewrite rules set up:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

This works fine, allowing me to use "nice" URIs (like www.mysite.com/about instead of www.mysite.com/about.php.

However, when I have both a directory and a file with the same name (for example /products and products.php, this breaks as apache just redirects to the directory. Is there a way to fix this?

Thanks,

1 Answer 1

1

You can remove RewriteCond %{REQUEST_FILENAME} !-d, but that's going to effectively disable your ability to browse directories or to load a DirectoryIndex page.

1
  • That does not seem to have any effect on my apache behaviour. I just took out that line completely, but it is still indexing the folder contents instead of going for the php file.
    – Goro
    Commented May 18, 2011 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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