Search | Directories | Reference Tools
UW Home > UWIN > Computing and Networking > Web > Web Publishing 

Creating Custom Error Messages

Summary

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.

Included on this page:

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. Create a Web page which contains your custom error message. The following steps refer to this Web page as "notfound.html".

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

  3. Log in to your Homer, Dante, or Shell.MyUW.net account.

  4. Press the O key for Other, then press the W key to drop into the Web development environment.

  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 /userid/notfound.html

    Replace "userid" 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 the .htaccess file (in Pico use ^X).

  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: