In this tutorial, we will remove the .php and .html prefix using our .htaccess file.

To start, head over to cPanel and click File Manager. On the top right of the page, you will see a settings button. Once you click that button you will be presented with some options, ensure "Show hidden files (dotfiles)" is enabled. Once you have enabled this navigate to the public_html folder and create a file called .htaccess, if you already have a .htaccess file, you may use that.

If you have a line called RewiteEngine On follow step 1. If you don't, follow step 2.

Paste this into your .htaccess file

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


Paste this into your .htaccess file

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


You should now see the changes made!
Was this article helpful?
Cancel
Thank you!