Forum Moderators: phranque

Message Too Old, No Replies

Weird combo 200-404 page header

         

wheel

7:05 pm on Oct 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just noticed some of my pages returning this as the page header:
HTTP/1.1 200 Ok 404 Not Found

Now, that's just not right :).

What I have is my 404 page set up as 'redirect.php'. That php script checks a database of page mappings, and if found is supposed to generate a 200 (page found) and generate the page. That way I can have URL mappings done right out of the database. If the page address isn't found in the database, we dump out a 404 not found.

It used to work fine - 404's when expected, 200's when expected. Not now - now when I expect a 404 I get that weird thing.

Any idea what would be causing that combination of codes header? I don't recall changing anything in the code.

g1smd

7:32 pm on Oct 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Have you got two HEADER directives in the script?

Or, is the server sending 200 for finding the script, and then the script is sending 404 after that, and the server is combining them?

I really really really do not like "redirect" scripts for sending errors, they often break the proper HTTP processes - as you have found.

It is quite common to find a "404 Error" that actually sends a 302 followed by a separate 200 - and that is very broken.

jdMorgan

8:30 pm on Oct 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Look at the code in your error-handling script, and if the logic is correct then try the following to override any/all defaults which might be set, and force a 404 response:

<?php
header("Status: 404 Not Found", true, 404);
?>

Jim

wheel

11:25 pm on Oct 6, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, I'll throw that past our developer. It just seems odd that this crops up after working fine for years.

What's perhaps interesting is that Google seems to be OK with this error on my part. I only noticed it because MSN was indexing a bunch of 404 pages from our site.

rocknbil

8:58 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Same problem! [webmasterworld.com] I'm using perl, and still haven't solved it, kinda set it aside.

g1smd

9:11 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I had forgotten that thread. It was only 10 days ago too: [webmasterworld.com...]

jdMorgan

1:00 pm on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



rocknbill,

I actually was going to refer back to your thread, but then remembered that you were using PERL.

In both cases, I believe the problem is that the "Status" response is a preamble to the HTTP response headers -- That is, it is much like a doctype declaration in HTML; The status response precedes the HTTP headers, but is not considered to be an HTTP header itself, much as a doctype precedes an HTML document, but is not HTML markup itself.

Therefore, I suspect that a "special" form of the "output a header function" must be used in both scripting languages, in order to send a properly-formatted HTTP status.

Also, the problem may have to do with running the script interpreters as cgi versus as installed modules... Did anybody's server get upgraded recently?

I'm hoping you guys find solutions, and post them back here. If so, I may do some editing to add some strong keywords to these threads, so that others can find them easily... :)

Jim