Hi i am working on a project where i have two index files on root, one is index.php and other is index.html. I want o set default page to index.php and if it is not available then it should work for index.html. I have searched alot on internet and found the following solution for this.
DirectoryIndex index.php index.html
I am using this code on my site:
<Directory "/home/zhengyu/webroot/engine5g/rentown.com/">
DirectoryIndex index.php index.html default.htm
</Directory>
I have also tried another way:
<Directory "/home/zhengyu/webroot/engine5g/rentown.com/">
DirectoryIndex index.php index.html
Options Indexes FollowSymLinks MultiViews
AllowOverride None
DirectoryIndex index.php index.html
Order allow,deny
allow from all
</Directory>
but none of them worked, it always makes index.php default, but when it is not available it doesn't load index.html.
and if I write index.html first and then index.php then it loads index.html, but doesn't load index.php if index.html not available.
In short, we can say that Preferences are not working.
You can specify multiple filenames, and the web server will search for each file until it finds a match. Consider this example directive:
Write this into your htaccess file on root:
Or try this way
Source:
https://www.a2hosting.com/kb/developer-corner/apache-web-server/default-directory-index-page
https://httpd.apache.org/docs/2.4/mod/mod_dir.html