htaccess 递归是如何工作的?

发布于 2024-11-05 23:57:57 字数 527 浏览 0 评论 0原文

我在托管环境中工作,主 webroot 位于 ~/www 中。我在 ~/www/__subdomains 中托管了多个子域。在主 webroot 中,我有一个 .htaccess 文件,它进行了一些小的重写。在我的两个子域中,我有类似的 .htaccess 文件,并且这些子域响应正确。

在另外 2 个新创建的子域中,我有 .htaccess 文件,这些文件为空,保存了 AddHandler 指令。我发现根 .htaccess 文件的存在/内容会影响这两个子域。他们抛出 500 错误。一旦我重命名该子域,损坏的子域就可以工作。

当然,这会破坏其他站点,因此我不能将其移走,但这违反了我对 .htaccess 递归工作原理的理解。我认为只要子目录中有 .htaccess 文件,祖先目录中的文件就永远不会被执行。

显然,我的想法是错误的,所以我希望有人可以教育我并帮助我解决这个问题。

谢谢。

I'm working in a hosted situation where I have a primary webroot located in ~/www. I have several subdomains hosted in ~/www/__subdomains. In the primary webroot, I have a .htaccess file that does a bit of minor rewriting. In two of my subdomains, I have similar .htaccess files and these subdomains respond properly.

In 2 other, newly created subdomains, I have .htaccess files that are empty save for an AddHandler directive. What I'm finding is that the root .htaccess file's existence/content affects these 2 subdomains. They throw a 500 error. As soon as I rename that one, the broken subdomains work.

This, of course, breaks the other sites so I can't just move this off, but it violates my understanding of how .htaccess recursion works. I thought that as long as there was a .htaccess file in a subdirectory, those in ancestor directories would never get executed.

Clearly, I'm wrong about that so I'm hoping someone can educate me and help me get this fixed.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

爱给你人给你 2024-11-12 23:57:57

.htaccess 文件从当前目录向上应用,在主配置处停止。当前目录的 .htaccess 文件中的任何规则和指令将取代进一步评估 .htaccess 时找到的任何其他规则。

然而,正如您所发现的,问题在于未明确覆盖的规则是从其他文件应用的。您可以参考 Apache .htaccess 教程以获得进一步的解释,特别是如何应用指令部分。

希望有帮助。

.htaccess files are applied from the current directory up, stopping at the main configuration. Any rules and directives that are in the current directory's .htaccess file, supersede any other rules found while evaluating .htaccess further up.

However, the problem, as you've found, is that rules that aren't explicitly overridden, are applied from the other files. You can reference the Apache .htaccess Tutorial for further explanation, specifically, the How directives are applied section.

Hope that helps.

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