problems using mod_headers with php-fpm/mod_fastcgi

落花浮王杯 提交于 2020-01-22 14:14:45

问题


I'm trying to add HSTS headers to every response, across my app.

My first thought was to use mod_headers — I placed this directive in an .htaccess file at the documentroot:

Header set Strict-Transport-Security "max-age=7776000"

This works fine on my local setup using Apache 2.2 and mod_php. All resources respond with the appropriate HSTS header.

My deployment environment uses Apache 2.2 and mod_fastcgi and the above technique works for any resource except php files.

Another SO question had a similar problem, where incoming requests (?) had headers stripped — but I'm concerned about modifying headers of response leaving the server.

How can I add response headers to php resources in the context of an .htaccess file?


回答1:


According to the docs for mod_headers you probably need to set the optional conditional flag for the header directive.

So in this case, it would become

Header always set Strict-Transport-Security "max-age=7776000"


来源:https://stackoverflow.com/questions/23160228/problems-using-mod-headers-with-php-fpm-mod-fastcgi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!