RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L]And if you want to add the trailing slash to the URL, use the following code instead:
# the following deals with the removal of the extension RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]+)/$ $1.php RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php # addition of the trailing slash RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$ RewriteRule (.*)$ /$1/ [R=301,L]For more information regarding apache’s rewrite module, please visit here. Of course this would require the rewrite module to be enabled on the hosted server which I won’t cover in this post, please refer to Apache’s online documentation.