How to Create A Custom Apache 503 Error Page

19,895

ErrorDocument takes in a absolute URL path instead of a file path. So it should be:

ErrorDocument 503 /blah/error.html

Assuming under your document root is a /blah/error.html file.

Share:
19,895
snowfi6916
Author by

snowfi6916

Updated on July 26, 2022

Comments

  • snowfi6916
    snowfi6916 almost 2 years

    I created an HTML document that will display that the server is not ready yet, and then redirect to another page. I want this to be the 503 error page.

    What file do I need to edit in Apache to get this custom HTML to be my new 503 error page? I have tried following the instructions on multiple websites, but it still points to the original Apache one.

    This is the code that I have in my "httpd-vhosts.conf" file.

    <VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName blah.blah.com
    ServerAlias blah blah.blah.local
    ErrorLog "logs/blah-error.log"
    CustomLog "logs/blah-access.log" common
    ErrorDocument 503 "D:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/blah/error.html"
    LogLevel warn
    RewriteEngine On
    JkMount /* worker5
    DocumentRoot "D:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/blah"
    <Directory "D:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/blah">
                Options All
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
    </VirtualHost>
    

    In the "httpd.conf" file, it is including the "httpd-vhosts.conf" file, so I don't know why it is not working. Any help would be appreciated. Thanks.

  • moderns
    moderns about 10 years
    It will not work this way because some errors code have to be configured from: /etc/apache2/conf.d/localized-error-pages
  • Welsh
    Welsh about 10 years
    No it doesn't. You can do ErrorDocuments in various contexts. See: httpd.apache.org/docs/2.2/mod/core.html#errordocument
  • Cerin
    Cerin over 6 years
    This answer doesn't make sense. 503 is shown when the site is down...but you're suggesting you add this to your site...which won't be shown when the site's down?
  • Welsh
    Welsh over 6 years
    If you are using Apache HTTP with a ProxyPass to display for example a NodeJS site, you can use this to return a custom, friendlier 503 instead of the default white screen if the upstream becomes unavailable.