I have made a website and am hosting it using Hostinger. Whenever I go to the website the domain name appears and at the end it will have /index.html or /about.html or /contact.html. Now when I go on other websites, they generally don't have the .html at the end but rather just the webpage name for example /home or /about.
I have tried searching this up but can't find any answers on it. I have also checked on browsers on other devices and it does the same. Could it be something to do with the way I've named my files or something with the hosting?
When you create a website, the URLs displayed are influenced by both the file naming structure and the server's configuration for handling those files.
Solution:
Since you are using Hostinger, your website is likely hosted on an Apache server, which supports .htaccess
files for URL rewriting. You can use an .htaccess
file to rewrite URLs so that they don’t include .html
. Here’s how to do this:
.htaccess
file..htaccess
file to remove .html from URLs:RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^.]+)$ $1.html [L]