【问题标题】:Apache mod_headers: can't edit set-cookie headerApache mod_headers:无法编辑 set-cookie 标头
【发布时间】:2016-12-13 09:56:40
【问题描述】:

我正在尝试使用mod_headers 修改 cookie 对其有效的域:

来自: ipa_session=e88331a44e20d8b5caaacb0e896029fe; Domain=internal.example.com; Path=/ipa; Expires=Tue, 13 Dec 2016 09:31:33 GMT; Secure; HttpOnly

收件人:ipa_session=e88331a44e20d8b5caaacb0e896029fe; Domain=example.com; Path=/ipa; Expires=Tue, 13 Dec 2016 09:31:33 GMT; Secure; HttpOnly

Mod-headers 运行良好,这些规则有效:

Header set "something" "something"
Header edit "something" "something" "somethingdifferent"

但是编辑“Set-Cookie”标题什么都不做:

Header edit "Set-Cookie" "Domain=internal.example.com" "Domain=example.com"

Apache 语法没问题,但规则什么也没做。

Apache 包版本:2.4.18-2ubuntu3.1

【问题讨论】:

    标签: apache cookies mod-headers freeipa


    【解决方案1】:

    必须在edit 之前添加always

    Header always edit "Set-Cookie" "Domain=internal.example.com" "Domain=example.com"
    

    在我的例子中,我也使用了edit*(替换所有匹配项)

    【讨论】:

      【解决方案2】:

      添加到 Misko 的响应(因为我的帐户太新无法评论)Apache 文档说响应标头来自两组内部表。因此,有些事情需要“总是”才能工作,而没有“总是”需要其他事情才能工作。就我而言,Ubuntu 18.04、Apache 2.4.29 我必须删除“始终”才能从 PHP 7.2 中编辑标题。

      文档似乎建议您可以同时使用这两个指令来涵盖所有基础,但我尚未对此进行测试。

      【讨论】:

      • 是的,我可以确认这一点。将我的网站移动到另一台服务器后,我不得不删除“总是”。
      猜你喜欢
      • 1970-01-01
      • 2020-02-02
      • 1970-01-01
      • 2020-06-29
      • 1970-01-01
      • 2021-01-08
      • 1970-01-01
      • 1970-01-01
      • 2014-02-26
      相关资源
      最近更新 更多