View Full Version : Remove .php add / not working in directorys

09-28-2010, 11:23 AM
I have the following code in my .htaccess file, just trying to remove the .php extension and add a slash.

http://www.somesite.com/file.php to /file/ works but
http://www.somesite.com/folder/file.php to /folder/file/ does not work

Options +FollowSymLinks -MultiViews
DirectorySlash Off
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php

# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]