Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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,

share|improve this question

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

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

1 Answer 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.

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

 
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.