Indiana University
University Information Technology Services
  
What are archived documents?
Login>>
Login

Login is for authorized groups (e.g., UITS, OVPIT, and TCC) that need access to specialized Knowledge Base documents. Otherwise, simply use the Knowledge Base without logging in.

Close

How do I create customized error messages for my web page?

Note: This information is applicable primarily to Unix systems running the Apache World Wide Web server, which runs on Mypage and Webserve at Indiana University.

Note: The IU South Bend Mypage service is different from the Mypage service noted here; see IUSB's Web Publishing: Mypage.

The easiest way to customize the error messages for your site is to use .htaccess files. With .htaccess files, you can make your web server substitute pages of your choice for the generic error messages it normally displays. You may designate different files for each error message, and with multiple .htaccess files, you may also create a set of messages for each part of your site.

Follow these instructions to customize your error messages:

  1. Create web pages for each of your customized error messages. It doesn't really matter where you put them, but make sure they are accessible to a web browser.

  2. Open the .htaccess file in a text editor like Emacs, vi, or Pico. You must pay more attention to where you place this file. The server will consult the .htaccess file every time it tries to access a page from the directory it's in, as well as any subdirectories. If you put another .htaccess file in a subdirectory, it will override .htaccess files in parent directories.

  3. The syntax for the .htaccess file is as follows: ErrorDocument ErrorCode Address Replace ErrorCode with the error number of the standard error message you want to replace (e.g., 401 , 403 , 404 , 500 ) and Address with the URL of the file you want as the replacement message, for example: ErrorDocument 403 http://mypage.iu.edu/~dvader/errors/forbidden.html ErrorDocument 404 http://mypage.iu.edu/~dvader/errors/unknown.html HTML error codes have the following meanings:
    401 Unauthorized. This indicates a password error, for example.
    403 Forbidden. The file exists, but isn't world readable.
    404 Unknown. The file doesn't exist at the location specified.
    500 Internal server error.

    If you already have an .htaccess file (to password-protect a directory, for example), just add the ErrorDocument lines to the end of it.

  4. Once you have finished, exit your editor and set the protections of the .htaccess file with the following command: chmod 644 .htaccess

At Indiana University, for personal or departmental Linux or Unix systems support, see At IU, how do I get support for Linux or Unix?

This is document agxp in domain all.
Last modified on May 13, 2009.

Comments/Questions/Corrections

Use this form to offer suggestions, corrections, and additions to the Knowledge Base. We welcome your input!

If you are affiliated with Indiana University and would like assistance with a specific computing problem, please use the Ask a Consultant form, or contact your campus Support Center.

Contact Information

Note: We will reply to your comment at this address. If your message concerns a problem receiving email, please enter an alternate email address.