How to make Apache to serve index.php
Many have noted that by default most of the server prefer to serve index.html eventhough we have other index page with different extensions like .php, .sh, .py etc . In this post we are going to see how we can make Apache to serve index.php instead of index.html and vice versa. This is purely depends on the DirectoryIndex of the Apache’s httpd.conf file. So we need to edit the DirectoryIndex preference in httpd.conf file.
To do this open your http.conf file and just search for DirectoryIndex option. You can see index.html is added first in the list. That is why the apache server prefer index.html over other extensions.
DirectoryIndex index.html index.php index.pl index.cgi index.asp index.shtml index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm
Here you can give the preference to your type of file which you would like to be loaded first. In the above configuration the preference is given to .html as it is loaded first in the DirectoryIndex.
Note: The DirectoryIndex will only work if the dir_module is enabled in your apache server.