【问题标题】:How are Apache Rewrite Rules Interpreted in Combination?Apache Rewrite 规则如何组合解释?
【发布时间】:2022-01-10 19:01:44
【问题描述】:

这一切都发生在 上下文中的 LAMP 堆栈上。我正在使用

RedirectPermanent / https://www.example.com/

将所有http请求重定向到https。我也有旧的传入损坏的“http://...”链接,我想重定向这些链接,这似乎是执行它们的最佳位置,而不是在 https 端,这将涉及将无意义的重定向发送到非- 找到 https 页面。

如果我像这样堆叠重定向:

RedirectPermanent /specific/2020/url1.php https://example.com/2021/url1.html
RedirectPermanent /specific/2020/url2.php https://example.com/2021/url2.html
RedirectPermanent /specific/2020/url2.php https://example.com/2021/url3.html

RedirectPermanent / https://example.com/

“url#”重定向和“/”重定向之间是否存在冲突的可能性?

我在 Apache 的文档中找不到任何内容来解释这些规则将如何组合解释。 “url1”的模式匹配是否以例如“L”标志与 RewriteRule 的方式终止脚本?

或者是否有可能应用“/”-> https 行,因为它也匹配?

【问题讨论】:

    标签: apache configuration url-rewriting virtualhost


    【解决方案1】:

    我想我在这里找到了答案:

    https://httpd.apache.org/docs/2.4/mod/mod_alias.html

    文档说:

    首先,在处理别名之前处理所有重定向,因此匹配RedirectRedirectMatch 的请求将永远不会应用别名。其次,别名和重定向按照它们在配置文件中出现的顺序进行处理,第一个匹配项优先。

    我更喜欢更明确的措辞,但我将其解释为当匹配发生时,随后的重定向将被忽略。

    【讨论】:

      猜你喜欢
      • 2011-02-19
      • 1970-01-01
      • 2013-07-24
      • 2012-03-23
      • 2019-09-13
      • 1970-01-01
      • 1970-01-01
      • 2011-07-20
      • 1970-01-01
      相关资源
      最近更新 更多