DirectoryIndex不起作用 [英] DirectoryIndex doesn't work
问题描述
我使用apache2来托管网站。我的目录中有index.html和index.php。
I use apache2 to host a site. There are both index.html and index.php in my directory.
我打开 /etc/apache2/apache2.conf
并添加一行:
DirectoryIndex index.php index.html index.htm
然后重启apache2。但是当我打开 localhost / ~username
时,它会访问index.html。
Then restart apache2. But when I open localhost/~username
, it accesses the index.html.
我环顾四周但是可以'找不到问题。我的httpd.conf是空的,我没有.htaccess文件。
I look around but can't find problem. My httpd.conf is empty and I don't have .htaccess file.
设置隐藏在哪里?
编辑:修改 /etc/apache2/mods-availiable/dir.conf
后,找到index.php。
Edit: After I modified /etc/apache2/mods-availiable/dir.conf
, it finds the index.php.
但为什么apache2.conf不能覆盖dir.conf?!
But WHY the apache2.conf can't overwrite dir.conf?!
推荐答案
我认为 mod_dir
未加载,尝试命令 sudo a2enmod dir
和服务apache2 restart
I think mod_dir
isn't loaded, try to command sudo a2enmod dir
and service apache2 restart
这篇关于DirectoryIndex不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!