Click here to Skip to main content
15,886,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried to set index.php as a default page in my PHP project which is running on apache. I edited httpd.conf file in path etc/httpd/conf/httpd.conf

<ifmodule dir_module="">
DirectoryIndex index.html index.php


Also, I did

DirectoryIndex index.php /var/www/html/index.php

but still, it doesn't load the index.php file but it loads the index.html file. Any clue to solve this issue. What am I doing wrong here.

What I have tried:

<ifmodule dir_module="">
DirectoryIndex index.html index.php


DirectoryIndex index.php /var/www/html/index.php
Posted
Updated 15-Sep-21 11:46am

1 solution

Simple.
The DirectoryIndex directive will use the first file it can find of the ones you list. So
DirectoryIndex index.html index.php
will use index.html if it exists, before it looks for index.php.

As always, it pays to read the mod_dir - Apache HTTP Server Version 2.4 documentation[^], which spells this out clearly.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900