10
votes

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?

5

5 Answers

13
votes

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.

0
votes

Try this:

DirectoryIndex index.html index.htm index.php index.php3

Precedence is from left to right, so if you happen to have both html will be preferred

0
votes

Silly question, but have you proven that your htaccess file is being utilized?

See: http://httpd.apache.org/docs/current/mod/core.html#allowoverride

0
votes

You have to check if there is any htaccess rule on parent directory that conflics with this rule, my problem was that, having a RewriteEngine on root directory and "/folder/" DirectoryIndex won't work.

-3
votes

open your .htaccess file and add

DirectoryIndex index.php