Michael LeVan
Michael LeVan

Reputation: 556

Change Apache Default Index File

I want apache2 to host home.php or whatever I choose as the start page instead of index.html. Everything I have read says to edit the DirectoryIndex parameter of the httpd.conf file. I do not have that file anywhere. (I searched.)

I also did not have an .htaccess file by default. I created one and put the line DirectoryIndex home.php in it; I then restarted apache. Nothing chaged.

This is in my apache2.conf file.

<Directory /var/www/html> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>

I am not sure what Options Indexes FollowSymLinks does.

These are the file contents of my /var/www/html/.htaccess.

<Directory /var/www/html> DirectoryIndex home.php </Directory>

When I change AllowOverride to All I receive a server error.

Thanks.

Upvotes: 2

Views: 14430

Answers (1)

Ren&#233; H&#246;hle
Ren&#233; H&#246;hle

Reputation: 27325

The best way is to add DirectoryIndex to your vhost configuration.

<Directory /foo>
    DirectoryIndex home.php
    Allow Override All
</Directory>

When you want to use that option ins your .htaccess file you have to set AllowOverride All in your vhost configuration. Otherwise you should get an error in your log DirectoryIndex not allowed here.

Upvotes: 3

Related Questions