Removing file extensions using htaccess Print

  • File extensions, htaccess
  • 0

Lately, there seems to be a trend where designers want to cloak their file extensions from their visitors. For example, they want the URL '' to display as '' for whatever reason.

Some like the way it looks, others believe it helps with SEO, and others believe it is better for security.

This is a feature you can implement via your htaccess file. This article will guide you through doing so via your cPanel.

How to remove file extensions from display via htaccess

Step 1. Log into your cPanel.
Step 2. Find the Files category and click on the File Manager icon.
Step 3. In the top right hand corner, click on Settings. For the primary domain, click on the Web Root radio button. For addon domains, click on the dropdown and find your desired addon domain name. Be sure the checkbox next to Show Hidden Files is checked. Click the Save button to return to the main File Manager screen.

Step 4. You should now be in the root folder of the domain you chose. Look for the .htaccess file and right click on it. This brings up a menu. Find and click on the Edit option. If you get a popup box, simply find and click the Edit button in the lower right corner to continue to the editor.

Step 5. You are now in the text editor. As most sites are coded with either htm or php, we have include 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

Step 6. Be sure to hit the Save Changes button in the upper right corner to save your new htaccess configuration. Your site should now display the address without the file extension.

Was this answer helpful?

« Back