Webmasters Stack Exchange is a question and answer site for pro webmasters. 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

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?


share|improve this question

migrated from serverfault.com May 16 '11 at 21:41

This question came from our site for system and network administrators.

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.

share|improve this answer
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 May 18 '11 at 17:45

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.