Howto remove .php, .html extensions on a web page using .htaccess file

28th Mar 2021 | category: Web Design and Development | Hits: 6171 Howto remove .php, .html extensions on a web page using .htaccess file

Many times you will want to have user-friendly URLs on your site. Instead of you will want to have . 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

Screenshot below shows how by default the website loads before removing or disabling the .php or html extensions.

Web page extension visible Web page extension visible

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.

Cpanel: Public_html - Activate "show hidden files"

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.

Web page without extension. Web page without extension.