How to remove file extension using htaccess
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 the 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 the 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.
1 2 3 | RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] |
Remove the 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.
1 2 3 | RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.html [NC,L] |
Please follow and like us: