Create Your Own Error Pages (Windows Webhosting)

In this article, we will show you how to replace the standard error pages with your own, custom error pages.

Your own error pages make it easier for your website visitors to understand complicated error messages from the web server. As an example, we will show you how to set up an error page for error message 404 (Not Found).

Create and Upload an Error Page

You first need your own error page, which will later replace the standard error page.

  • Create a file named error_404.html and paste the following content:
    <?xml version="1.0" ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Error 404</title>
    </head>
    <body>
    <h3>This should not have happened. The page you requested does not exist anymore.</h3>
    <p><a href="index.html">Go to the Home page</a></p>
    </body>
    </html>
  • Upload the file error_404.html into the desired directory on your webspace. If the error page is to be displayed for the entire webspace, store it in the root directory.

Customise Webspace Configuration

To replace the standard error pages of the server with your own error pages, it is necessary that you edit the configuration file web.config in your webspace. There you can define the desired error page for each error.

  • Open web.config with a text editor and look for the section htttpErrors which is intended for the entry of the error pages:
    <httpErrors errorMode="Custom">
    .
    .
    </httpErrors>
  • Tell the web server which page to display for which error. For example, if you want your error page error_404.html to be displayed for pages not found, enter the following statement:

    <error statusCode="404" path="error_404.html" />

    If you want to replace other standard error pages with your own error pages, add them there. The complete section could then look like this:
    <httpErrors errorMode="Custom">
    <clear/>
    <error statusCode="404" path="error404.html" />
    <error statusCode="500" path="error500.html" />
    </httpErrors>
    The additional statement ensures in this case that your change cannot be overwritten by any other web.config if, for example, it is located in a parent directory.
Please Note:

You can also disable individual error pages completely. As a result, however, the web server issues an internal system error message instead, which can be very general. For example, in case of error 404, you get the message "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

If you want to do this for error 404, for example, use the following statement:
<remove statusCode="404" subStatusCode="-1" />