fbpx

How To Remove File Extensions using .htaccess In cPanel

In this tutorial, I will show you how to remove file extensions using .htaccess in cPanel.

There are different types of files in .htaccess, and it may include files like php, html, or asp files. However, having most of this files in your server may affect your website’s SEO and you may want to remove the file extensions that are unnecessary. Following this guide, you can easily complete the process.

Let’s get started.

How To Remove File Extensions Using .htaccess In cPanel

  • Log into your cPanel.
  • Go to the Files section and select File Manager.
remove file extensions
  • In the File Manager, go to the .htaccess file. If you can’t locate it, you can set the File Manager to show hidden files.
  • Right-click on the .htaccess file and select Edit from the pop-up option that appears.
remove file extensions
  • You will be taken to the text code editor. Since most sites are coded with php or html, I have outlined the code for both below:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1.html
  • When you are done, you click on Save Changes.

You have successfully removed file extensions using .htaccess in cPanel. If you have any questions, leave it in the comment section. I will love to hear from you.

Leave a Reply