Hello guys, In this article, we will explain to you how to remove file extension using htaccess. so we will give you a simple example of how to remove file extension in htaccess or how to remove .php, .html, .htm extensions with .htaccess.

Note: the Apache mod_rewrite module must be enabled. Otherwise, the following snippet will not work.

Remove php extension using htaccess
If you want to remove .php extension from a php file. for example yoursite.com/about.php to yoursite.com/about. so can follow htaccess script.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Remove html extension using htaccess
If you want to remove .html extension from a html file. for example yoursite.com/about.html to yoursite.com/about. so you can follow htaccess script.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]