|
Author: David van Geyn
Date: 18-11-01 18:04
Upon reading the brief statement you made about using Error404 for running a PHP script in this article:
http://www.freebsddiary.org/oclug.php
I decided to try it out. The problem I found was with Microsoft browsers that were set to 'Use Friendly HTTP Error Messages'. I believe, because the Apache server still sends back a HTTP/1.0 404, Microsoft Internet Explorer then displays it's generic and very simple error message saying the file could not be found. If that option is disabled, it works fine. It also works fine in Netscape, and in Lynx (however, in Lynx, it still does say in the
status bar "File Not Found", then continues and proceeds to load your error page. So, I think the problem is that Microsoft decided to not even display the error message the server produces, and just made its own.
Is there a way to get Apache to send back a 201, or whatever it is, instead of a 404? Or how would one get around this problem? Or can PHP send a second header or something, or one that receeds the Apache 404 header? I'm not really sure how this works...
Thanks for any information you can provide,
David van Geyn
|
|
Reply To This Message
|
|
Author: Dan Langille
Date: 21-11-01 22:36
Can you post code? Provide a URL which demonstrates? Or give me the code to create a demo page. I'll put it on <A HREF="http://test.freebsddiary.org/">http://test.freebsddiary.org/</A>.
|
|
Reply To This Message
|
|
Author: David van Geyn
Date: 22-11-01 20:02
That was all the code needed.
If using the ErrorDocument 404 handler to call a PHP script, and you don't want the server sending along an "HTTP/1.1 404 Not Found" header, adding 'header("HTTP/1.1 200 OK");' at the top of your PHP script seems to do the trick.
|
|
Reply To This Message
|
|
Author: Joshua
Date: 09-12-01 23:39
The problem with sending the 200 code is that the agent then believes it got a valid page. If it's a browser, it gets added to the history list. If it's a spider, the page gets crawled. I'm not sure, but I imagine that it doesn't show up in the server log as an error.
|
|
Reply To This Message
|
|
Author: Dan Langille
Date: 10-12-01 01:50
A 200 code would only be sent if the URL provided by the user actually resolved to something reasonable. I'll give an example.
The best application of this feature would be for <A HREF="http://www.FreshPorts.org/">FreshPorts</A> to allow URLs such as this:
http://www.FreshPorts.org/security/logcheck/
The Error404 handler would invoke a .php page, which would lookup security/logcheck and redirect it to <A HREF="http://www.freshports.org/port-description.php3?port=2691">this page</A>. You'll admit, the above URL is easier than the link just here... In which case, it will return a 200.
If the php script can't find a page to resolve to, it just does The Right Thing (TM) and provides a 404.
Does that makes sense now?
|
|
Reply To This Message
|
|
Author: Joshua
Date: 11-12-01 19:12
It's early and I've only had one cup of coffee so far, so forgive if this is a thinko...isn't that kind of thing what mod_rewrite is for? Isn't that what FreshPorts is doing?
<a href="http://httpd.apache.org/docs/misc/rewriteguide.html">the Apache 1.3 URL Rewriting Guide</a> has all the juicy details.
While writing that, I put back another cup and I still think it's mod_rewrite :)
|
|
Reply To This Message
|
|
Author: Cymen Vig
Date: 21-04-02 04:54
Simply load a graphic on the 404 page or more text! Microsoft displays their "pretty" 404 error page only when the 404 page loaded is less than a certain number of bytes. I don't remember the particulars but a bit of experimentation should answer the question quickly.
|
|
Reply To This Message
|
|