.htaccess 文件未被读取(.htaccess 文件中的“Options -Indexes"不起作用) [英] .htaccess file not being read ("Options -Indexes" in .htaccess file not working)

查看:27
本文介绍了.htaccess 文件未被读取(.htaccess 文件中的“Options -Indexes"不起作用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个仅包含以下行的 .htaccess 文件:

I created an .htaccess file with only the following line:

选项 - 索引

但是,仍然显示目录的索引.

However, the index is still shown for the directory.

我刚刚安装了 Apache2 并且使用了所有默认值(我没有修改 apache2.conf 或 httpd.conf).

I just installed Apache2 and am using all the defaults (I did not modify apache2.conf or httpd.conf).

操作系统:Ubuntu 12.04(精确穿山甲)
Apache2 版本:服务器版本:Apache/2.2.22 (Ubuntu) 服务器构建时间:2012 年 2 月 13 日 01:51:56

$ ls -l .htaccess
-rwxr-xr-x .htaccess

$ ls -l .htaccess
-rwxr-xr-x .htaccess

我听从了 lanzz 的建议,在 .htaccess 文件中添加了胡言乱语,发现 .htaccess 文件没有被读取.

I took lanzz's advice and added gibberish to the .htaccess file, and discovered that the .htaccess file is not being read.

推荐答案

为了使这个工作正常,我将以下内容添加到 /etc/apache2/httpd.conf(这是一个零长度文件默认情况下安装 Apache 时),然后重新启动 Apache.现在 .htaccess 文件中的 Options -Indexes 可以正常工作了.这是使其工作所需的最低要求:

To get this working, I added the following to /etc/apache2/httpd.conf (which is a zero-length file by default when Apache is installed) and then restarted Apache. Now Options -Indexes in the .htaccess file works as desired. Here is the bare minimum required to get it to work:

/etc/apache2/httpd.conf :

<VirtualHost *:80>
        DocumentRoot /var/www
        <Directory / >
        </Directory>
</VirtualHost>

lanzz 建议在 .htaccess 文件中添加一行乱码看看它是否被读取有助于诊断问题.

lanzz's suggestion to add a line of gibberish to the .htaccess file to see if it was being read was helpful in diagnosing the problem.

请注意,AllowOveride 默认为 All,根据 Evan Mulawski 的注释,因此在上面的 httpd.conf 行的最小集合中不需要它.

Note that AllowOveride defaults to All, per Evan Mulawski's comment, so it's not required in the minimal set of httpd.conf lines above.

这篇关于.htaccess 文件未被读取(.htaccess 文件中的“Options -Indexes"不起作用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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