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.

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 June 26, 2012.

I need help with a computing problem

  • Fill out this form to submit your issue to the UITS Support Center.
  • Please note that you must be affiliated with Indiana University to receive support.
  • All fields are required.



Please provide your IU email address. If you currently have a problem receiving email at your IU account, enter an alternate email address.

I have a comment for the Knowledge Base

  • Fill out this form to submit your comment to the IU Knowledge Base.
  • If you are affiliated with Indiana University and need help with a computing problem, please use the I need help with a computing problem section above, or contact your campus Support Center.