【问题标题】:Add a header to each request using .htaccess使用 .htaccess 为每个请求添加一个标头
【发布时间】:2010-12-06 22:34:00
【问题描述】:

我想在不接触代码的情况下将自定义标头添加到 phpbb 安装中。 (使用 .htaccess)

标题是:

Strict-Transport-Security: max-age=157680000

有什么想法吗?

【问题讨论】:

  • +1;有趣的问题。由于您不想使用 .htaccess,我假设您可以访问服务器系统。只是好奇,但你为什么不通过 h​​taccess 解决这个问题?
  • 我不想编辑 vanilla phpbb 安装。

标签: php .htaccess


【解决方案1】:
Header add Strict-Transport-Security "max-age=157680000"

http://httpd.apache.org/docs/2.0/mod/mod_headers.html

【讨论】:

  • 我会添加检查模块是否已加载。
    Header add Strict-Transport-Security "max-age= 157680000"
  • 如果行为是可选的,我只会测试模块。不然调试起来比较麻烦……
  • 别忘了激活apache模块头a2enmod headers
【解决方案2】:

http://httpd.apache.org/docs/2.0/mod/mod_headers.html

Header add Strict-Transport-Security "max-age=157680000"

【讨论】:

  • 我尝试将其添加到 .htaccess 文件中,但它只会产生 500 内部服务器错误。
  • 别忘了激活apache模块头a2enmod headers
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-11-25
  • 2021-09-28
  • 1970-01-01
  • 2018-12-10
  • 1970-01-01
  • 2016-03-31
  • 2020-07-18
相关资源
最近更新 更多