1

I want to have pretty urls so http://www.domain.com/foo will return http://www.domain.com/foo.php

The issue is that there is a directory that has the same name. I have another page at http://www.domain.com/foo/bar/baz and right now my server just returns the directory listing of foo when I request http://www.domain.com/foo

Pseudocode:
If the request plus ".php" is a file
rewrite out the file instead of the directory

Actual Code:

RewriteEngine On  
RewriteBase /  
RewriteCond %{SCRIPT_FILENAME}\.php -f  
RewriteRule (.*) $1.php [NC,L]
Jesse
  • 297
  • 1
  • 3
  • 9

2 Answers2

0

MultiViews could cause this behavior. Try to disable it.

Gumbo
  • 643,351
  • 109
  • 780
  • 844
0

You need to use the whole path:

RewriteCond "%{DOCUMENT_ROOT}%{REQUEST_FILENAME}.php" -f  

REQUEST_FILENAME is just the full path inside DocumenRoot

Jürgen Hötzel
  • 18,997
  • 3
  • 42
  • 58