Cannot change HTTP status after 404

software development


Hi All!

I have a .htaccess file that says:

ErrorDocument 403 /404test.php
ErrorDocument 404 /404test.php

and I have a PHP file (404test.php) that says:

<?php header("HTTP/1.0 200 OK", true, 200); print "all done!\n"; ?>

Obviously, this isn’t going to output anything useful, but I would expect the output to be delivered with a HTTP 200 status code. But instead, it has a 404 code which I don’t seem to be able to override.

Any ideas?

BTW - this has worked on my own Apache/PHP installation running on Ubuntu. So I’m guessing this might be something to do with the way DH manage their servers?


After a lot of digging around, I found some example code that also created a “status” header. So basically, if I change my php to read:

<?php header("HTTP/1.0 200 OK"); header("Status: 200 OK"); print "all done!\n"; ?>

… then it works!

I haven’t a clue why though. It doesn’t actually output a header named “Status” but I guess the PHP engine is interpreting the “status” header… but then I still don’t understand why this affects DreamHost and not my Ubuntu/Apache/PHP installation.

If anyone has any ideas as to why I need to do this, I’d be intrigued.


Is your ubuntu/apache installation running mod_php or PHP-CGI? I’n, wondering if that is the reason for the difference … just guessing here; I have not researched it. :wink:



I think all the settings are the default ones. So the control panel says:

PHP Version: PHP 5.2.x
Extra Web Security: YES
Fast CGI Support: NO

If running mod_php or PHP-CGI would’ve required me uploading anything and installing it… then no I didn’t do that; I’d remember! :smiley:


Nope, you wouldn’t have done a thing - it’s all about how DreamHost has PHP installed.

You can tell what mode PHP is running in by inspecting the output of phpinfo(). If you do this on DreamHost and on your system,and compare the results, you can identify all the salient differences between your two setups. :wink:



Yeah, looks like you’re spot on! The significant difference between my Ubuntu machine:
Server API: Apache 2.0 Handler

…and DH:
Server API: CGI/FastCGI

…is FastCGI. After even more digging around, it looks like it’s a known “issue” (I’ll remain impartial and not call it a bug or even a feature!), as documented here:
and possibly here:

Anyway, that’s wrapped it up for me! It looks like it’s not an issue specific to DH, but to anyone using PHP via CGI.

Thanks for your help!! :smiley:


Good deal! I suspected that might be the case … I’m sorry I don’t know of a good “work-around”. At any rate, I’m glad you got it figured it out!