Apache won't set headers for PHP script

柔情痞子 提交于 2019-12-17 20:25:36

问题


This .htaccess file:

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 4 month"
</IfModule>
<IfModule mod_headers.c>
    Header merge X-ModHeaders "Yes, it is installed"
</IfModule>

... works as expected in my development box (Windows box, Apache/2.4.10, PHP running as Apache module), where "works" means that it generates the appropriates headers for all resources (static or dynamic).

However, in my production server (Linux box, Apache/2.2.31, PHP running as FastCGI with mod_fcgid/2.3.9) it only works for static assets, not for PHP scripts.

Am I right suspecting that difference comes from the PHP SAPI? Is there a way to fix it so I don't need to duplicate the code that generates HTTP headers?


回答1:


If PHP is running via mod_proxy_fcgi there might be no filesystem directory involved, hence no htaccess lookup can occur.

There is a more recent flavor of php+mod_proxy_fcgi now documented in the manual that uses SetHandler instead of ProxyPass -- that allows things like htaccess to be processed because the core actually looks up the URL in the filesystem as a first step.



来源:https://stackoverflow.com/questions/32147413/apache-wont-set-headers-for-php-script

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