I was using .htaccess code to remove .php extension for all my web pages. Here\'s the code I use:
RewriteEngine On
RewriteCond /%{REQUEST_FILENAME}.php -f
Re
It seems like the slash at the end of your rule might be there, or it might not. Adding a ?
makes it optional, so that mysite.com/about
and mysite.com/about/
will both match.
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-\s]+)/?$ /$1.php
It's hard to say if this is what's causing your problem, or if something else is, though. Does mysite.com/about.php
also give you an error?
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# If folder does not exist
RewriteCond %{REQUEST_FILENAME} !-d
# and file exist
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
# uncomment the below rule if you want the "/" to be required
# otherwise leave as is
# RewriteRule ^([^/]+)/$ $1.php [L]
# internally show the content of filename.php
RewriteRule ^([^/]+)/?$ $1.php [L]
The above rule will:
/
if one is present as the file nameSo it will work for all these examples:
http://domain.com/about/
http://domain.com/about
http://domain.com/contact/
http://domain.com/contact
If you want you can remove the ?
, like the commented rule, to make it accept only URL's that end with a /
.
http://domain.com/about/
http://domain.com/contact/
Now these are important step for the above to work:
.htaccess
on your root folder for example /home/youraccount/public_html/.htaccess
-MultiViews
.htaccess
is for example in your case the about.php
file