You are not logged in.

#1 2012-01-15 21:45:02

bjackman
Member
Registered: 2011-12-27
Posts: 32

[Solved] Apache doesn't seem to recognise ErrorDocument directive

I'm trying to put a custom 404 page on my server. I added this line to /etc/httpd/conf/httpd.conf

 ErrorDocument 404 /not_found.html 

not_found.html is found in /srv/http, which is my DocumentRoot.

I've tried restarting the server, putting not_found.html in the ServerRoot, and even in /. I also tried changing "/not_found.html" to "notfound.html" and "@@DocumentRoot@@/not_found.html" and "/srv/http/not_found.html". Apache still serves up in the default "Object not found!" page when you request something nonexistent.

The other peculiar thing, possibly a clue, is that it still puts server information (version, OS etc.) at the bottom of the page, despite me having turned ServerTokens and ServerSigniature off, which is supposed to supress this information. These directives have had the desired effect on "index" pages - the line is doesn't appear.

Could anyone suggest why I can't seem to change this behaviour at all? Perhaps there is somewhere I could find some detailed logs of httpd's behaviour? /etc/httpd/logs/error_log just logs the fact that a nonexistent page was requested, not what action it took.

Thanks.

Last edited by bjackman (2012-01-17 19:39:06)

Offline

#2 2012-01-17 03:51:53

lfitz
Member
Registered: 2011-11-29
Posts: 6

Re: [Solved] Apache doesn't seem to recognise ErrorDocument directive

Try this:

in /etc/httpd/conf/httpd.conf search for <Directory />.

You'll find this:

<Directory />
    ...
    AllowOverride None
    ...
</Directory>

change AllowOverride from 'None' to 'FileInfo' and put ErrorDocument 404 /not_found.html on the next line...

<Directory />
    ...
    AllowOverride FileInfo
    ErrorDocument 404 /not_found.html
    ...
</Directory>

I was able to replicate the problem on my server.  The comments above the default <Directory /> line, in httpd.conf, should explain why this happens.

Last edited by lfitz (2012-01-17 04:12:25)

Offline

#3 2012-01-17 19:38:53

bjackman
Member
Registered: 2011-12-27
Posts: 32

Re: [Solved] Apache doesn't seem to recognise ErrorDocument directive

lfitz wrote:

Try this:

in /etc/httpd/conf/httpd.conf search for <Directory />.

You'll find this:

<Directory />
    ...
    AllowOverride None
    ...
</Directory>

change AllowOverride from 'None' to 'FileInfo' and put ErrorDocument 404 /not_found.html on the next line...

<Directory />
    ...
    AllowOverride FileInfo
    ErrorDocument 404 /not_found.html
    ...
</Directory>

I was able to replicate the problem on my server.  The comments above the default <Directory /> line, in httpd.conf, should explain why this happens.

Brilliant, exactly what I was looking for. Thanks very much.

Offline

Board footer

Powered by FluxBB