I have two index files in my public_html folder (Apache), index.html and index.php
By default Apache seems to be directing traffic to index.php, so I want to change that to index.html. I added a .htaccess file in the same directory with this in it:
DirectoryIndex index.html
But when visitors go to the website (www.example.com/), they are still directed to index.php
Why is this?
The DirectoryIndex directive sets the list of resources to look for, when the client requests an index of the directory by specifying a / at the end of the directory name. Local-url is the (%-encoded) URL of a document on the server relative to the requested directory; it is usually the name of a file in the directory.
If you want the directory index page setting to apply to your entire web site, add the DirectoryIndex directive to the . htaccess file in the public_html directory. All subdirectories beneath it that do not have their own . htaccess file will inherit the setting.
For those who are still searching for the answer - just like the OP suggests, add the following line to your .htaccess file:
DirectoryIndex index.php
Make sure your hosting is allowing htaccess override in httpd.conf
AllowOverride All
If it's not enabled, you'll have to contact your hosting provider.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With