为什么我无法在 Apache 中禁用 .htaccess?

发布于 2024-07-14 14:44:44 字数 750 浏览 9 评论 0原文

这与我读过的大多数问题相反。 我在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云雾 2024-07-21 14:44:45

AllowOverride 仅允许在-部分,所以您已经完成了所有正确的操作。

您可能遇到的一个问题是其他(子)部分将 AllowOverride 设置为与 None 不同的内容。 这将覆盖这些子目录的设置。
我使用

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride AuthConfig 
    Order allow,deny
    allow from all
</Directory>

并且在 /var/www (我的文档根目录)中我可以使用 .htaccesses。

如果删除 .htaccessmod_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 set AllowOverride to something different than None. That will override the setting for these subdirectories.
I use

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride AuthConfig 
    Order allow,deny
    allow from all
</Directory>

and in /var/www (my docroot) I can use .htaccesses.

The reason why mod_python does not work anymore if you delete your .htaccess is that mod_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 not None in <Directory />.

自由如风 2024-07-21 14:44:44

当您删除 .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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文