Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does index.html have priority over index.php?

Tags:

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?

like image 802
Akos Avatar asked Oct 24 '11 09:10

Akos


People also ask

What is the point of index html?

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.

What is the purpose of index PHP file?

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


2 Answers

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.

like image 176
MarioRicalde Avatar answered Sep 21 '22 11:09

MarioRicalde


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

like image 21
Alix Axel Avatar answered Sep 22 '22 11:09

Alix Axel