Howto remove .php, .html extensions on a web page using .htaccess file28th Mar 2021 | category: Web Design and Development | Hits: 6080
Many times you will want to have user-friendly URLs on your site. Instead of https://www.mydomain.com/index.html you will want to have https://www.mydomain.com/index . The second URL looks much better. Also, from the SEO point of view it is better to don’t use file extensions. For my tutorial purpose I am using a domain url https://www.bbscargoltd.comt/about.php which in conclusion i will be able to access it via https://www.bbscargoltd.com/about
Screenshot below shows how by default the website loads before removing or disabling the .php or html extensions.
used one of the boostrap done website with static pages.
Access your root folder where your website is, in our case the website is configured in Cpanel. Therefore through file manager we access the .htaccess file under the public_html directory.
NOTE: For .htaccess file to be visible in file manager you need to enable “show hidden files (dotfiles)”. To activate click on the Settings button on the top right corner. Then Save.
Edit .htaccess file
Right click on .htaccess file and open the file. If the file doesn’t exist you will need to create it.
Add the below lines to the .htaccess file. Click the Save Changes button and then the Close button.
After successfully saving the file you can navigate through your menu (if a static website) and remove the extension .php and .html extensions wherever in the code.
This is how your new site url will be after saving the files.