目录索引不起作用 [英] DirectoryIndex doesn't work

查看:41
本文介绍了目录索引不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 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 dirserviceapache2重启

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

这篇关于目录索引不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆