Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

With Apache, is it possible to send a 404 status header, but then send valid content? Because that's what's happening right now with http://doubleabody.com on a2hosting.com right now. The web logs show all connections (besides the homepage) to be a 404 status, but then the browsers are receiving valid content after that. This causes something strange to happen. In IE, when it has Friendly HTTP Errors turned on, it's displaying the 404. In IE, with Friendly HTTP Errors turned off, it's not displaying the 404 and is displaying the content just fine. In all other browsers, they seem to be seeing valid content and ignoring the 404 error that the server is recording.

This problem used to not occur until 2 weeks ago, and the only thing that has changed in 14 months on the site has been the Apache system updates like normal. (I will admit that the client asked me to edit the homepage template and show a message to IE users about the problem.)

I want to prove that this is a misconfigured Apache config. I have downloaded the database and the hosting files for this WordPress site, and I'm now going to troubleshoot to see if the same code also has a problem on my workstation.

But the question still stands -- can Apache return a 404 status header and still return valid XHTML after that?

share|improve this question
    
I just took a look at this in IE with Friendly HTTP Errors turned on and indeed all of the links return a 404 "The webpage cannot be found". –  Kev Mar 27 '11 at 17:32

1 Answer 1

up vote 4 down vote accepted

Yes. A 404 doesn't imply no content. You can legitimately serve a 404 plus content, such as a guess as to what the user actually wanted, or a helpful and pretty error page with links to your docs, etc. In this particular case, I'm guessing that the front controller is configured to use smart URLs, i.e., that there's no actual file for a page named /page. This most likely means that Apache is configured (with mod_rewrite) to send all requests for files that don't exist to /index.php (or similar), which then decides which content to serve for the URL. It appears that it's not then explicitly setting the status to 200 once it picks the correct content. I don't think this is an Apache config issue, but a WordPress config issue.

Edit: Perhaps your .htaccess file is sending the missing file redirect to /index.php with an explicit 404 status.

share|improve this answer
    
Thanks. I'll look into this. –  ServerChecker Mar 27 '11 at 17:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.