Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache won't set headers for PHP script

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?

like image 667
Álvaro González Avatar asked Sep 26 '22 23:09

Álvaro González


1 Answers

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.

like image 140
covener Avatar answered Oct 20 '22 13:10

covener