I have a virtual server running apache2 on debian. I would like to create a default 404 error message in the apache2.conf for all my websites.

ErrorDocument 404 "/var/www/site/public/404.html"

The error I get after restarting apache is: Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

It works if I enter the URL although I dont want the page to redirect only use a default 404.html page.

link|improve this question

+1 for humorous irony – Chris S Aug 10 '11 at 17:14
I've never seen a 404 loop – Mike Aug 10 '11 at 17:19
I don't know whether to be happy with the vote ups or embarrassed it was a daft question. – John Magnolia Aug 10 '11 at 22:12
feedback

1 Answer

up vote 5 down vote accepted

You don't use the full path in ErrorDocument. Its relative to your htdocs root

http://httpd.apache.org/docs/2.0/mod/core.html#errordocument

if your root is /var/www/site/public/

ErrorDocument 404 /404.html

You can also do a full url

ErrorDocument 404 http://domain.com/404.html

EDIT

You can do this for each vhost then

Alias /404 /full/path/to/404.html
ErrorDocument 404 /404
link|improve this answer
Thank you, although is there anyway to do this without having to upload 404.html to each vhost website? Maybe I could add an alias for the 404.html, is this the best way? – John Magnolia Aug 10 '11 at 17:24
edited my answer for an alias in there – Mike Aug 10 '11 at 17:30
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.