我使用apache2来托管一个站点。我的目录中有index.html和index.php。
我打开/etc/apache2/apache2.conf并添加一行:
DirectoryIndex index.php index.html index.htm然后重新启动apache2。但是当我打开localhost/~username时,它会访问index.html。
我环顾四周却找不到问题。我的httpd.conf是空的,我没有.htaccess文件。
布景可能藏在哪里?
编辑:我修改了/etc/apache2/mods-availiable/dir.conf之后,它找到了index.php。
但是为什么apache2.conf不能覆盖dir.conf呢?!
发布于 2015-04-29 11:29:49
我认为mod_dir没有加载,尝试命令sudo a2enmod dir和service apache2 restart
发布于 2011-06-28 16:12:03
在希望发生此行为的目录中创建一个名为.htaccess的文件。在.htaccess文件中,以DirectoryIndex开头放置一行,在请求目录时首先使用文件名列表,如下所示:
DirectoryIndex index.php index.html index.htm index.phtml start.html上述指令必须全部位于.htaccess文件中的一行上。
https://stackoverflow.com/questions/6509549
复制相似问题