How to remove .php from the end of URLs with .htaccess
October 26, 2018
If you have files such as hello.php
and you want users to be able to go to yoursite.com/hello, use the following code:
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.php [NC,L]
A request to http://yoursite/asdf will try and use the file /asdf.php.
Don't forget that you will probably need to enable the rewrite engine for these rules to work. Click the button below to find out how to do this.