How to remove the .php extension using htaccess

A .htaccess file is a file located at your webserver which enables you to make changes to some of the Apache options without having to modify the httpd.conf Apache configuration file or restarting the webserver. Making changes in the httpd.conf file requires a reboot of the webserver. Most webservers allow htaccess modifictations to a certain extend. The only disadvantage of using a htaccess is, every time a http request is made, it has to read the htaccess file, resulting in a slower delivery time.
This is the htaccess file I use to remove the .php extension to create clean urls. All you have to do is create a .htaccess file. Unless hidden files are visible on your hard drive you shouldn‘t name it .htaccess at first, but rename it when you‘ve uploaded it to your web space, because all files beginning with a dot become automatically hidden. So, just leave out the dot at first.
Leave out the “L” flag which indicates this is the last rule to follow in this set if you want to add more rules. The NC flag means it has to ignore the case of the request.
RewriteEngine On
RewriteBase /
RewriteRule ^()$ index.php [NC,L]
RewriteCond % !(^/?.*..*$) [NC]
RewriteRule (.*)$ $1.php [NC]
At the website of htaccessediter.com you can easily create htaccess files without any knowledge of apache or htaccess whatsoever.
Posted on 20-07 by Steven Dobbelaere
Thanks for your comment. I've overlooked that. It's now corrected.Posted on 20-07 by Neal Jansons
Minor correction...the syntax is case-sensitive. Rewritecond should be RewriteCond.