Debian – Error when creating a custom ErrorDocument 404 in apache

apache-2.2debianweb-server

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.

Best Answer

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