【发布时间】:2012-06-01 22:46:36
【问题描述】:
我创建了一个只有以下行的 .htaccess 文件:
选项-索引
但是,该目录的索引仍然显示。
我刚刚安装了 Apache2 并且使用了所有默认值(我没有修改 apache2.conf 或 httpd.conf)。
操作系统:Ubuntu 12.04 (Precise Pangolin)
Apache2版本:Server version: Apache/2.2.22 (Ubuntu) Server built: Feb 13 2012 01:51:56
$ ls -l .htaccess
-rwxr-xr-x .htaccess
编辑:
我听取了lanzz的建议,在.htaccess文件中添加了乱码,发现.htaccess文件没有被读取。
【问题讨论】:
-
尝试在 .htaccess 中放置一行乱码,看看您在访问网站时是否遇到内部服务器错误。如果您没有收到错误,则您的 .htaccess 根本没有被读取。
-
Options -Indexes怎么样? -
你的 httpd.conf 中是否设置了
AllowOverride All? -
@Ansari:OP 使用默认值,根据httpd.apache.org/docs/2.0/mod/core.html,默认情况下在
All上。 -
在 .htaccess 中尝试了一行乱码,并且在 error.log 中没有错误,所以显然 .htaccess 根本没有被读取。那么为什么不读取 .htaccess 文件呢?