为什么我无法在 Apache 中禁用 .htaccess?
这与我读过的大多数问题相反。 我在使用 Apache 2.2.8 的 Amazon 实例上运行 Ubuntu 8.04,我不明白为什么将 root 的 AllowOverride 设置为 None 不会阻止包含我的 .htaccess 文件。
我有一个包含 hello.py 的子目录和一个 .htaccess 文件。 当我浏览到该文件时,它可以与 modpython 一起正常运行该文件。 如果我在 .htaccess 中放入一些垃圾,则会收到服务器错误,因此我知道 .htaccess 文件正在被使用。 另外,如果我删除 .htaccess 文件,hello.py 不再是 modpython 的服务器 - 相反,浏览器会尝试打开它。
在我的可用站点之一(在启用站点中链接)中,我的根目录为“AllowOverride None”。 我认为这会阻止 .htaccess 被包含在根目录及其所有子目录中,这会导致 mod_python 不提供 hello.py 服务。 但是,它仍然运行良好,我可以测试 .htaccess 是否仍然包含在内,因为当我修改它时,我会在浏览器中看到结果。
也许我对启用站点的文件有一些不理解的地方。 这是我正在使用的文件:
NameVirtualHost *:8080
<VirtualHost *:8080>
<Directory />
AllowOverride None
</Directory>
</VirtualHost>
感谢您的帮助。
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.
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.
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>
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
AllowOverride
仅允许在
-部分,所以您已经完成了所有正确的操作。您可能遇到的一个问题是其他(子)部分将
AllowOverride
设置为与None
不同的内容。 这将覆盖这些子目录的设置。我使用
并且在
/var/www
(我的文档根目录)中我可以使用.htaccess
es。如果删除
.htaccess
,mod_python
不再起作用的原因是mod_python
设置通常位于.htaccess
中> 文件。如果您需要更多信息,请将您的配置发送给我们。
PS:事实上,上面链接的文档表明,您不应该永远将
AllowOverride
设置为中不是
。None
的内容。AllowOverride
is only allowed in<Directory>
-sections, so you've done everything right.One problem you could have is that other (sub-)
<Directory>
-sections setAllowOverride
to something different thanNone
. That will override the setting for these subdirectories.I use
and in
/var/www
(my docroot) I can use.htaccess
es.The reason why
mod_python
does not work anymore if you delete your.htaccess
is thatmod_python
setup is usually in.htaccess
files.If you need more information, please send us your configuration.
PS: In fact the docuementation linked above says that you should never set
AllowOverride
to something notNone
in<Directory />
.当您删除 .htaccess 时,该文件不通过 mod_python 提供的原因是因为 mod_python 的设置位于其中。 如果您将这些内容移至站点可用文件中,则可以删除 .htaccess,对问题视而不见,然后就到此为止。
如果这不能让您满意,那么至于为什么 .htacess 会被读取,我不能说。 您是正确的,AllowOverride None 应该阻止文件被读取。 您是否考虑过在添加虚拟站点时搞砸了一些事情的可能性? 尝试将一些垃圾放入配置中,看看它是否会抱怨,只是为了确保它被读取。
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.
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.