Knowledgebase

Hide php or html extensions with htaccess

Thanks to .htaccess we can hide our .php/.html extensions of our files within the url when accessing our website. In this way, it will not be necessary to enter the full path and it will be accessible both WITH and WITHOUT extension.

To achieve this we simply must add this small code in our .htaccess file to eliminate the php extensions. The first thing we have to do is access the cPanel of our service of hosting. If the .htaccess file does not exist, we must create one and place it in the root directory of our hosting plan (inside the public_html folder). In the case of .html extensions we will use the same code changing .php for .html.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
  • 91 Users Found This Useful
Was this answer helpful?

Related Articles

Prestashop update

Update Prestashop To update Prestashop to the new version, the following steps will be carried...

Viruses on the web. Help!!! What are they and how do we eliminate them?

Lately, cases of websites that are infected by viruses or malicious code, without the webmaster...

How can I manage the domain?

For everything related to the administration of your domain, you must use the CPANEL control...

What is a subdomain?

Subdomains are extensions that we can use with our domain, for example, suppose that our domain...

How to publish my website?

To upload the content of your website to the server you can use any FTP client such as FileZilla,...