为什么我不能在 Apache 中禁用 .htaccess? [英] Why can't I disable .htaccess in Apache?

查看:39
本文介绍了为什么我不能在 Apache 中禁用 .htaccess?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这与我读过的大多数问题相反.我在使用 Apache 2.2.8 的 Amazon 实例上运行 Ubuntu 8.04,但我不明白为什么将 AllowOverride 设置为无 root 不会阻止我的 .htaccess 文件被包含在内.

This is the opposite problem from most about which I have read. I am running Ubuntu 8.04 on an Amazon instance with Apache 2.2.8 and I can't figure out why setting AllowOverride to None for root doesn't stop my .htaccess file from being included.

我有一个包含 hello.py 的子目录和一个 .htaccess 文件.当我浏览到该文件时,它与提供该文件的 modpython 一起工作正常.如果我在 .htaccess 中放入一些垃圾,我会收到服务器错误,所以我知道正在使用 .htaccess 文件.此外,如果我删除 .htaccess 文件,hello.py 不再是 modpython 的服务器 - 而是浏览器尝试打开它.

I have a sub-directory with hello.py in it and an .htaccess file. When I browse to the file, it works fine with modpython serving the file. If I put some garbage in .htaccess I get a server error, so I know the .htaccess file is being used. Also if I delete the .htaccess file, hello.py is no longer server by modpython - instead the browser tries to open it.

在我的一个可用站点(在启用站点中链接)中,我的根目录具有AllowOverride None".我认为这会阻止 .htaccess 被包含在 root 及其所有子目录中,这会导致 hello.py 不被 mod_python 服务.但是,它继续提供良好的服务,我可以测试 .htaccess 是否仍然包含在内,因为当我修改它时,我会在浏览器中看到结果.

In one of my sites-available (linked in sites-enabled), I have "AllowOverride None" for the root directory. I thought that this would prevent .htaccess from being included from root and all its sub-directories which should cause hello.py to not be served by mod_python. However, it continues to be served fine and I can test that .htaccess is still being included because when I modify it, I see the results in my browser.

也许我不了解启用站点的文件.这是我正在使用的文件:

Maybe there is something I am not understanding about my file in sites-enabled. This is the file I am using:

NameVirtualHost *:8080 
<VirtualHost *:8080>
<Directory />
AllowOverride None
</Directory>
</VirtualHost>

感谢您的帮助.

推荐答案

删除 .htaccess 时文件未通过 mod_python 提供的原因是因为 mod_python 的设置位于其中.如果您将这些内容移到您的站点可用文件中,您可以删除 .htaccess,对问题视而不见,然后收工.

The reason the file is not served via mod_python when you delete .htaccess is because the setup for mod_python is located in it. If you move that stuff to your sites-available file, you can delete .htaccess, turn a blind eye to the problem, and call it a day.

如果这不满足您,那么至于为什么要读取 .htacess,我不能说.AllowOverride None 应该阻止文件被读取是正确的.您是否考虑过在添加虚拟站点时出现问题的可能性?尝试将一些垃圾扔到配置中,看看它是否会抱怨,以确保它正在被读取.

If that doesn't satisfy you, then as to why .htacess is being read at all, I can't say. You are correct that AllowOverride None should prevent the file from ever being read. Have you considered the possibility that you screwed something up when adding the virtual site? Try throwing some garbage into the config and see if it complains, just to be sure it's being read at all.

这篇关于为什么我不能在 Apache 中禁用 .htaccess?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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