SyntaxHighlighter

Wednesday, 14 December 2011

PHP header 200 Status Not Being Sent

I'm having a real mare with this PHP site I am working at the moment. Having constant configuration problems - grrr!

I am using a .htaccess file to handle the a 404 (ErrorDocument 404 /404.php). It's used to handle friendly URLs mainly. One of the other things I use it for is allowing JavaScript files to be PHP processed before they are served to the browser. This is dead useful as I can modify and customise the scripts where required.

Anyway...
In the code I use header("HTTP/1.1 200 OK") and in nearly all instances that works fine. Except for when it is processing the the JavaScript files. After massive annoyance and trying loads of different things, it turns out there is a bug in PHP 5. As they suggest at the bottom, the workaround is:

header("Status: 200 OK");

Fixed!