htaccess – error pages

  Web Hosting, htaccess, Settings

You can use the htaccess file to set up web pages for visitors to see when an error occurs.

The ErrorDocument command can be used to:

  • redirect to another URL (any)
  • view the content of a particular page on the same site
  • display the set error message

The first parameter is the error number, the second parameter is the destination URL, file or text.

Examples

ErrorDocument 500 http://www.example.com/error.html
ErrorDocument 404 /page-doesnt-exist.php
ErrorDocument 401 /login.html
ErrorDocument 403 "Sorry, you do not have access to this file"

HTTP error codes

For example, the HTTP protocol defines the following error codes:

  • 01 Unauthorized – user must log in to access
  • 403 Forbidden – Access Denied
  • 404 Not Found – Page Not Found
  • 500 Internal Server Error – internal error, request cannot be processed (eg error in script)

A complete list of codes and their explanations: HTTP 1.1 – status code definitions

Děkujeme za zpětnou vazbu!