Facebook  Twitter  Google +  Linkedin


Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/lwegabab/public_html/old/plugins/content/al_facebook_comments/al_facebook_comments.php on line 516

Warning: file_get_contents(https://api.facebook.com/restserver.php?method=links.getStats&urls=https://www.old.yourictmagazine.com/howtos/923-howto-remove-php-html-extensions-on-a-web-page-using-htaccess-file): Failed to open stream: no suitable wrapper could be found in /home/lwegabab/public_html/old/plugins/content/al_facebook_comments/al_facebook_comments.php on line 516

Warning: Undefined array key 1 in /home/lwegabab/public_html/old/plugins/content/al_facebook_comments/al_facebook_comments.php on line 521

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 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.

Howto remove .php, .html extensions on a web page using .htaccess fileNote: 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.

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

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.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

 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.

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