Possible Duplicate:
remove .php extension with .htaccess
I know little about .htaccess, What I'm trying to accomplish is two-fold.
Allow requests to .php to be called with or without the .php and with or without a trailing slash. For example.
/profile.php
works
/profile
appends .php, works
/profile/
append .php so it worksIf the file or directory doesn't exist after trying the above, then treat as a 404 and redirect to another page.
/something
failure, redirect to /404.php?id=$1 (url requested)
I have two rules that work separately, but I need to conditionalize these or something. Any advice would be appreciated.
RewriteEngine on # This works for the PHP part. RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]*)/?$ $1.php # This works for general 404 handling RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /404.php?url=http://%{HTTP_HOST}/$1 [L]