I have a website on a server. The homepage is example.com/index.php .
OK, I uploaded an index.html named file to the server (the root dir) and when I typed in my site's domain into the browser's URL bar, I was suprised, because the index.html page loaded.
(example.com->example.com/index.html) So not what I wanted.
My question: Why did that happen? Why does index.html have advantage over index.php?
The index. html page is the most common name used for the default page shown on a website if no other page is specified when a visitor requests the site. In other words, index. html is the name used for the homepage of the website.
The index. php file for a template contains a mixture of code that will be delivered as it is, and PHP code that will be modified before it is delivered. The code will be familiar to anyone who has designed a simple HTML web page. There are 2 main sections - the <head> and <body>.
It really depends on the Server you're using. This is a matter of configuration. It's not that there's any advantage from using html vs php filetype.
You could say that the .html
variation takes precedence due to the fact that it's the most basic web format.
If you're using Apache, just check the default .htaccess
setup:
DirectoryIndex index.html index.shtml index.php index.htm default.html Default.htm default.html Default.html default.shtml Default.shtml page1.html index.pl index.cgi index.php3 index.phtml home.htm home.html home.shtml index.wml
You can edit that and make it fit your needs.
@kuroir is right, that depends on the web server configuration, in Apache it's the DirectoryIndex
:
DirectoryIndex index.html index.php index.cgi
That will give priority to .html
files over .php
files, and priority to .php
files over .cgi
files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With