6

I use apache2 to host a site. There are both index.html and index.php in my directory.

I open the /etc/apache2/apache2.conf and add a line:

DirectoryIndex index.php index.html index.htm 

Then restart apache2. But when I open localhost/~username, it accesses the index.html.

I look around but can't find problem. My httpd.conf is empty and I don't have .htaccess file.

Where may the setting hide?

Edit: After I modified /etc/apache2/mods-availiable/dir.conf, it finds the index.php.

But WHY the apache2.conf can't overwrite dir.conf?!

3
  • 1
    If you temporarily remove index.html from the directory (eg rename it) does it find index.php? Commented Jun 28, 2011 at 16:18
  • Yes. If I rename it to index.htm, apache find index.php Commented Jun 28, 2011 at 16:20
  • 1
    Did you ever find a solution to this? I have the exact same problem where if I edit the dir.conf file, it works, but anywhere else (except for htaccess), it doesn't override it :( Commented Jun 12, 2013 at 23:16

2 Answers 2

1

I think mod_dir isn't loaded, try to command sudo a2enmod dir and service apache2 restart

Sign up to request clarification or add additional context in comments.

1 Comment

This is not an answer to this question; you just gave it to another one?
0

Create a file named .htaccess in the directory where you want this behavior to occur. Inside the .htaccess file, put a single line beginning with DirectoryIndex followed by the list of filenames that you want Apache to serve first when a directory has been requested, like so:

DirectoryIndex index.php index.html index.htm index.phtml start.html 

The above directive must be all on a single line in the .htaccess file.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.