To hide the .php or .html extensions in the URL of a website hosted with Hostinger, you can use the .htaccess file. The .htaccess file is a configuration file that allows you to control various aspects of how your website functions, such as redirects, error handling, and URL rewriting.
Steps to hide .php in htaccess hostinger
To hide the .php or .html extensions using the .htaccess file, follow these steps:
- Access the file manager in the HPanel control panel.
- Navigate to the root directory of your website.
- If you don’t see a .htaccess file, create a new file and name it .htaccess.
- Open the .htaccess file and add the following code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
This code will hide the .php extension from the URL, so that your website’s URLs will appear as “www.example.com/page” instead of “www.example.com/page.php”.
Steps to hide .html in htaccess hostinger
To hide the .html extension in Hostinger using an .htaccess
file, you can follow these steps:
- Login to your Hostinger account and go to the File Manager section.
- Navigate to the root directory of your website where your
.htaccess
file should be located. If you don’t have one, create a new file named.htaccess
. - Open the
.htaccess
file for editing. - Add the following code to the
.htaccess
file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
- Save the
.htaccess
file.
This code uses the mod_rewrite
module to redirect requests for URLs that don’t end with .html
to their corresponding .html
files. For example, if you have a file named about.html
, you can access it using the URL http://example.com/about
instead of http://example.com/about.html
.
Note that this code assumes that your .html
files are located in the same directory as your .htaccess
file. If your .html
files are located in a subdirectory, you’ll need to modify the RewriteRule
accordingly.
Keep in mind that hiding the .php or .html extension from the URL can have some technical implications, such as the need to update any links or references to your website’s pages. It’s a good idea to test your website thoroughly after making these changes to ensure that everything is working as expected. If you are not familiar with .htaccess or URL rewriting, it may be a good idea to consult with a web developer or the customer support team at Hostinger for assistance.