I'm trying to set up custom error pages (403, 404, etc) on an Apache 2.2 setup. I know that on IIS7.5 the pages are stored in


but am not sure where they are (or even if they exist) on Apache. Is there a .config file I need to change or something similar?

  • Also, I've posted it on SF rather than webmasters.stackexchange as there's 4k+ questions tagged on SF for "apache" – tombull89 Feb 1 '11 at 12:33

Usually such information is defined in your .htaccess. Eg:

ErrorDocument 500 http://foo.example.com/cgi-bin/tester
ErrorDocument 404 /cgi-bin/bad_urls.pl
ErrorDocument 401 /subscription_info.html
ErrorDocument 403 "Sorry can't allow you access today" 

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

  • is this not for a per-site basis though? or is there a "master" .htaccess for all sites on that Apache install? – tombull89 Feb 1 '11 at 12:49
  • 2
    On Apache, the .htaccess files provide overrides to the standard configuration - which is stored in httpd.conf - where that file is will depend on how your apache was compiled and options on the command line used to start it (have a look in the directory tree where you installed apache). The ErrorDocument must be within the current vhosts document tree - so it makes sense to either define this within the vhost config or via a .htaccess file. – symcbean Feb 1 '11 at 13:55

This is normally just within the default DocumenRoot for the server. While this may be a bad example, cPanel stores it's default 404's in /usr/local/apache/htdocs/

Stock configurations will also load them from wherever the default document root is for all of the other non-matching requests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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