Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is location for standard Apache Error Document for 404?

I am working on customizing various error codes for apache and I know the way to do it. (By adding new pages and referencing them in the /etc/httpd/conf/httpd.conf against the various error codes.

My question here is - where does the standard error message for apache come from? For example if I run my local apache and try to browse a non existing URL, I get following error.

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /not_found was not found on this server.</p>
<hr>
<address>Apache/2.2.15 (CentOS) Server at localhost Port 80</address>
</body></html>

My httpd.conf does not have any ErrorDocument overrides. So this is standard apache error. When I grep, I don't find any file containing these texts.

So does that mean this is coming from an apache module?

like image 986
user1401472 Avatar asked Aug 19 '14 06:08

user1401472


People also ask

What is a 404 error Apache?

A 404 error page indicates that the page we are trying to access is not able to locate. It is also known as the File Not Found page. At Bobcares, we often get requests regarding Apache errors, as a part of our Server Management Services.

Why Apache server does not work Error 404?

The domain no longer exists. The requested resource has been deleted or moved to a different URL. The URL was mistyped into the browser.


2 Answers

Answering my own question:

The error comes from "c" file and apache does not have an default error html as I thought initially. Httpd source can be http://httpd.apache.org/download.cgi.

Refer to "src\main\http_protocol.c" file and below is code that throws 404 exception with the given message.

case NOT_FOUND:
        ap_rvputs(r, "The requested URL ",
              ap_escape_html(r->pool, r->uri),
              " was not found on this server.<P>\n", NULL);
        break;
like image 162
user1401472 Avatar answered Nov 15 '22 00:11

user1401472


Its probably under /usr/share/apache2. On my system the file is /usr/share/apache2/error/HTTP_NOT_FOUND.html.var. Maybe your grepping didn't find it because it is a type-map file (see these pages for details).

like image 35
jotik Avatar answered Nov 15 '22 01:11

jotik