Remove page extensions using htaccess Print

  • .htaccess, htaccess, seo-friendly-url
  • 0

Creating a SEO Friendly URL has become much more easier now a days. Sometimes, developers don't want to show their page extensions to the visitors which is also preferred for creating SEO Friendly URL. Such as, the URL 'yourdomain.com/index.html' to display as 'yourdomain.com/index' on browser's address bar. Some like the way it looks, others believe that its helpful for SEO. This is a feature that one can implement via .htaccess file. This article is a step by step guide on 'Remove page extensions using htaccess'.

    1. Login to your cPanel.
    2. Search for File Manager.
    3. Click on File Manager icon.
    4. In the top right hand corner, click on Settings. For the primary domain, click on the Web Root radio button. If you want to change this setting for a addon domain, 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 & the browser will return to File Manager screen.
    5. You should now be in the root folder of the domain you chose. Search for the .htaccess file, 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.
    6. 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

  7. Make sure that you 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

Powered by WHMCompleteSolution