Forum Moderators: phranque

Message Too Old, No Replies

200 OK not found?

Apache returns 200 OK when file is not found

         

thiebes

10:52 pm on Sep 12, 2006 (gmt 0)

10+ Year Member



I apologize if this has already been covered -- I tried searching and found a lot of things that don't exactly answer my question. If you know where I can look to find the answer, please share!

I'm new to administrating web servers, and I've found today that when I go to a page that doesn't exist, Apache is saying 200 OK, but then also says "The requested URL /whatever.html was not found on this server." Which, of course, makes no sense and is totally silly.

I'm running mod perl, mason and php. Help?

jdMorgan

11:02 pm on Sep 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might want to use Firefox with the Live HTTP Headers extension, and track *all* the server responses -- I suspect you'll find a 302 redirect to the error page, followed by a 200-OK response on that page.

The most common cause for this is an incorrect URL-path specification of the ErrorDocument directive. That is:

ErrorDocument 404 http://example.com/404.html will return a 302 foloowed by a 200, whereas
ErrorDocument 404 /404.html will return the expected 404 response.

This behaviour is described in the Apache core ErrorDocument documentation.

Jim

thiebes

11:54 pm on Sep 12, 2006 (gmt 0)

10+ Year Member



Thanks very much for the quick response and the suggestion! I have installed the extension and it looks like it's giving 200 OK the first time. There's only one response:

HTTP/1.x 200 OK
Date: Tue, 12 Sep 2006 23:26:51 GMT
Server: Apache/1.3.29 (Unix) PHP/4.3.6 mod_perl/1.29 mod_ssl/2.8.16 OpenSSL/0.9.7d
Keep-Alive: timeout=15, max=93
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

Any other tips? Thanks in advance.

thiebes

10:24 pm on Sep 13, 2006 (gmt 0)

10+ Year Member



Incidentally there is no custom 404 page specified either. So I am just seeing the default, which has the header, then says "OK" in large font and "The requested URL /whatever.html was not found on this server." in the regular text size.

jdMorgan

1:51 am on Sep 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What kind of URL are you requesting that does not exist? (example.com example, please)

If it is a straight static html page URL, then your server is broken. If it is a script URL with appended variables, then Apache will only determine that the script exists; detection and handling of non-existent or invalid query string parameters will be up to the script, and it's possible that the error-handling in the script is faulty, and that it outputs the incorrect server response code.

Jim

thiebes

2:09 am on Sep 14, 2006 (gmt 0)

10+ Year Member



It's an intranet, so I can't give you an example that you can use. But the name of the server is thoth, and the URL looks like:

[thoth...]

It's not a script and you could plug any page name in there -- if the page doesn't exist, it will give the results described above.

I'm not sure what you mean by the server is broken. Of course it is! I'm trying to figure out how to fix...?

Thanks again for your responses.

Alex_TJ

12:59 pm on Sep 14, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



I have the same the same problem - the first part was solved by jdMorgan's reply changing the path to relative, but it's still not returning the correct header on the 2 subdomains.
www.example.com now returns 404
www.offshoot.example.com returns 200
I tried uploading an separate copy of the custom error page and even another copy of htaccess (deleting from it the 301 redirects for the files in www.example.com) to that subdomain's folder, but then the server starting using the second htaccess file and none of the 301 redirects worked for example.com
Any ideas what I'm still doing wrong?

jdMorgan

9:31 pm on Sep 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> I'm not sure what you mean by the server is broken. Of course it is! I'm trying to figure out how to fix...?

That was not clear until you answered my question about whether the pages were static or dynamic. This is a common point of confusion, in that Apache cannot check the validity of dynamically-generated pages, if those pages are generated based on a query string. Only the script can do that.

You'll need to review your server configuration in httpd.conf, conf.d, and all .htaccess files in the path to the highest-directory-level (non-existent) pages that exhibit this behaviour. Look for unexpected proxy passthrough invocations, Alias, Redirect, or mod_rewrite directives that may be getting involved in the serving of these pages. Also, if content-negotiation is currently on (See "Options MultiViews" in Apache core docs) and you don't use it, then turn it off.

Jim

thiebes

6:55 pm on Sep 18, 2006 (gmt 0)

10+ Year Member



Thanks again very much for your guidance. I'll check it out.