.htaccess DirectoryIndex not working

I have two index files in my public_html (Apache) folder, index.html and index.php

By default, Apache seems to direct traffic to index.php, so I want to change it to index.html. I added the .htaccess file to the same directory with this in it:

DirectoryIndex index.html

But when visitors go to the site (www.example.com/), they are still focused on index.php

Why is this?

+7
source share
5 answers

For those who are still looking for an answer - just like the OP suggests, add the following line to your .htaccess file:

DirectoryIndex index.php 

Make sure your hosting allows htaccess overrides in httpd.conf

 AllowOverride All 

If it is not enabled, you need to contact your hosting provider.

+8
source

Try the following:

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

Priority is from left to right, so if you are lucky enough to use both html

0
source

open the .htaccess file and add

 DirectoryIndex index.php 
0
source

Stupid question, but have you proven that your htaccess file is being used?

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

0
source

You should check if there is any htaccess rule in the parent directory that creates this rule, my problem was that having RewriteEngine in the root directory and "/ folder /" DirectoryIndex would not work.

0
source

All Articles