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/products.html‘ to display as ‘yourdomain.com/products‘ on browser’s address bar. Some like the way it looks, others believe that its helpful for SEO. That’s why they need to remove page extensions. and this is a feature that one can implement using .htaccess file. This article is a step by step guide on ‘How to remove page extensions using htaccess’.
-
- Login to your cPanel.
- Search for File Manager.
- Click on File Manager icon.
- 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.
- 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.
- 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.
PHP Extension:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
HTML Extension:
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.
We hope this tutorial helps you find the perfect solution. If your like our tutorials, definitely you’ll love our support. All VernalWeb hosting plans include 24/7 support from our amazing inhouse support staff. Check out our web hosting plans and have your website migrated today!