You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "David P. Donahue" <dd...@ccs.neu.edu> on 2005/07/27 16:44:37 UTC

[users@httpd] Custom 404 ErrorDocument Logs a 200

(Using Apache 1.3.33)  I have my httpd.conf file specify custom error 
pages for 404 errors (and some other errors, but that's not important). 
  I'm noticing in my logs, however, that when a user goes to a 
non-existant page and the server returns the custom 404 page, it's 
logged as a 200 instead of a 404.  I'm guessing this is because the 
custom page exists so the request was handled as a 200.

Is there a way to make it log as a 404?  I only ask because I have a 
reporting engine looking through my logs and it's registering far fewer 
404s in the reports than it should.  That and web crawlers aren't 
getting the hint that those pages aren't there :)

Any ideas?


Regards,
David P. Donahue
ddonahue@ccs.neu.edu
http://www.cyber0ne.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Custom 404 ErrorDocument Logs a 200

Posted by "David P. Donahue" <dd...@ccs.neu.edu>.
> <?php
> 
> header("HTTP/1.0 404 Not Found");
> 
> header("Expires: Mon, 26 Jul 2001 05:00:00 GMT");
> 
> header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
> 
> header("Cache-Control: no-store, no-cache, must-revalidate");
> 
> header("Cache-Control: post-check=0, pre-check=0", false);
> 
> header("Pragma: no-cache");
> 
> ?>

You definitely sent me in the right direction for finding the answer. 
It looks like adding the following to my Page_Load function (this is 
using c# with Mono, I've actually never used php) does the trick:

Response.StatusCode = 404;
Response.StatusDescription = "Not Found";

Though the response header seems a bit... stripped down.  I didn't want 
to mess with the header too much, since .NET has some background stuff 
going on.  But I can research that further.

In any event, thanks for the help!


Regards,
David P. Donahue
ddonahue@ccs.neu.edu
http://www.cyber0ne.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Custom 404 ErrorDocument Logs a 200

Posted by Kevin O'Neil <ke...@verizon.net>.
From: "David P. Donahue" <dd...@ccs.neu.edu>
To: <us...@httpd.apache.org>
Sent: Wednesday, July 27, 2005 10:44 AM
Subject: [users@httpd] Custom 404 ErrorDocument Logs a 200

> Is there a way to make it log as a 404?  I only ask because I have a 
> reporting engine looking through my logs and it's registering far fewer 
> 404s in the reports than it should.  That and web crawlers aren't 
> getting the hint that those pages aren't there :)
> 
> Any ideas?



I use this header in my 404 page:

<?php

header("HTTP/1.0 404 Not Found");

header("Expires: Mon, 26 Jul 2001 05:00:00 GMT");

header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

header("Cache-Control: no-store, no-cache, must-revalidate");

header("Cache-Control: post-check=0, pre-check=0", false);

header("Pragma: no-cache");

?>

It seems to work. 

If this is incorrect, please let me know.

Thank you,

Kevin



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org