How to remove .php, .html, .htm extensions with .htaccess

Krishna Jagadeesh
Sep 3, 2018 · 1 min read

what is .htaccess file ?

.htaccess is a configuration file for use on a web server,running on the Apache web server
software.It provides a way to make configuration change on directory basic.

#Some features of .htaccess file
1.Redirect the user different page
2.Password protect a specific directory
3.Block user by IP address
4.Preventing hot links to your images
5.Rewrite urls
6.Specify your own error documents

#How to use it?
Let’s create .htaccess file in cpanel

now the add following code in .htaccess file in cpanel

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

Krishna Jagadeesh

Written by

Programmer, tinkers around in business, Big data, blockchain and AI.