How to make Apache to serve index.php

By | July 27, 2016

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.

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.

How to make Apache to serve index.php

How to make Apache to serve index.php

Note: The DirectoryIndex will only work if the dir_module is enabled in your apache server.

Leave a Reply