Removing file extensions using htaccess

Removing file extensions using htaccess

  1. Log into your cPanel.
  2. Find the Files category and click on the File Manager icon.
  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.
  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.
  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
  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.


Leave a Reply