I've got my .htaccess file set to the following:
Header set MyHeader "I'm Set!"
If I go to that directory (http://example.com/test/
), which has no default index file, and view the network activity (in this case with Chrome), I can see that the header is being sent. If I go to a php file (http://example.com/test/test.php
), the header isn't sent.
I've created an index.html (with simply <pre>Hi
as the content) and it gets sent. I change the file name to .php
, no header. If I change the orignal test.php
to test.html
, it outputs the garbage-looking code, and the header is sent. If I change test.php
to test.png
, I get a broken image icon, and the header is sent.
So, without testing beyond the above in terms of mime-type and file extensions, it appears only .php
files (legit or otherwise) are either set to not have .htaccess rules apply or specifically the mod_headers directives. But I don't know how to test for this and because it's a shared server, I don't have httpd.conf
access to poke around.
Any ideas as to why apache would skip sending headers for php files?
I've also tried:
<FilesMatch "\.(php)$">
Header set MyHeader "I'm Set!"
</FilesMatch>
This is expected behavior when running CGI scripts. From the latest (2.4) version of the mod_headers docs:
The original issue (with, perhaps, a better explanation) is in Bug 49308.