Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
RewriteRule ^([^/]+)/?$ $1.php [L]
The above rule will:
- will not redirect if a folder exist
- will not redirect if the file does not exist
- will redirect what comes before the
/
if one is present as the file name
So it will work for all these examples:
http:
http:
http:
http:
If you want you can remove the ?
, like the commented rule, to make it accept only URL's that end with a /
.
http:
http:
Now these are important step for the above to work:
- It must go into the
.htaccess
on your root folder for example /home/youraccount/public_html/.htaccess
- The Options before the rewrite rule are very important specially
-MultiViews
- The file must exist on the same place the
.htaccess
is for example in your case the about.php
file
- The PHP must be working obviously.