更改Apache默认索引文件


Change Apache Default Index File

我希望apache2托管home.php或我选择的任何内容作为起始页,而不是index.html。我读到的所有内容都说要编辑httpd.conf文件的DirectoryIndex参数。我哪儿都没有那个文件。(我搜索了一下。)

默认情况下,我也没有.htaccess文件。我创建了一个,并将行DirectoryIndex home.php放在其中;然后我重新启动了apache。没有什么可懊恼的。

这在我的apache2.conf文件中。

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

我不确定Options Indexes FollowSymLinks做什么。

这些是我的/var/www/html/.htaccess的文件内容。

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

当我将AllowOverride更改为All时,我收到一个服务器错误。

谢谢。

最好的方法是将DirectoryIndex添加到vhost配置中。

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

当你想在.htaccess文件中使用该选项时,你必须在vhost配置中设置AllowOverride All。否则,您的日志DirectoryIndex not allowed here中会出现错误。