views:

59

answers:

2

I want to add several headers to all PHP output on my server. In a perfect world, I could just use Apache2s' mod_headers, but unfortunately I'm using WordPress "pretty permalinks", so my PHP files do not end in .php, thus I cannot use the FilesMatch directive. Changing the permalinks to include .php is not an option.

So is it possible to modify all PHP output (server-wide) in some other way?

I would even be content to apply my custom headers to all text/html, but I don't think there is a way to target output by MIME-type with Apache2.

(NOTE: If we can figure this out and the solution is server-related, I'll move this question over to ServerFault.)

+1  A: 

You can use an auto_prepend file, setup in your php.ini, to add the required headers.

philjohn
+1  A: 

You could try setting the auto_prepend_file in your php.ini to include a php file in which you could then set the headers using the header() function.

frglps
Will give that a try in a minute. I don't think this will work for me, however, because other (WordPress) `header()` calls will override my own.
Jeff
in that case you could possibly use the auto_append directive, but be sure to start output buffering in the auto_prepend file and then after setting headers in the auto_append flush the buffer.
philjohn