Skip Navigation
IT Connect
Connecting You to Information Technology at the UW

 

Creating Custom Error Messages

IT Connect > Web > Publishing > Custom Error Messages

You can create your own custom error messages to substitute the default error messages generated by the server, such as the common "404 Not Found." Use custom error messages when you want to display friendlier error messages to your visitors.

Introduction

Custom error messages can be used:

How To Create Custom Error Messages

The following instructions show how to create a custom error message to replace the default "404 Not Found" message.

  1. StepsActions
  2. Create a Web page which contains your custom error message. The following steps refer to this Web page as "notfound.html".

  3. Upload "notfound.html" to your public_html directory and verify that it can be opened with a Web browser.

  4. Log into your web development server using a terminal emulator. If you're not sure how to do this, click here for instructions.

  5. At the prompt, enter the following command to change directories to your Web directory:

    cd public_html
  6. At the prompt, enter the following command to create a .htaccess file in the current working directory:

    pico .htaccess
  7. To create a custom "404 Not Found" message, add the following line to this file:

    ErrorDocument 404 /uwnetid/notfound.html

    Replace uwnetid with your UW NetID and, if need be, notfound.html with the filename containing your custom error message.

    Tip: You can add additional lines with other error codes (eg 404, 403, 500) you wish to replace. Note that you may have each error code listed only once per .htaccess file; refer to the examples below.

  8. Save and close the file using Pico. (Click for instructions on how to use pico).

  9. You're done!

Note: Microsoft Internet Explorer does not display custom error messages by default; it displays its own built-in messages. You can change this by unchecking the "Show Friendly HTTP Messages" options found under "Tools" > "Internet Options" > "Advanced". Of course, it is doubtful that your visitors will have this option unchecked, and thus they might not see your custom error messages.

Examples and Resources

Here are some examples:

Note: 404 (Not Found), 403 (Not Authorized), and 500 (Server Error) are "response codes" defined in the HTTP specification.

To learn more about custom error messages and the ErrorDocument directive refer to: