By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

Custom Error Pages In htaccess

Tutorial showing how to create your own error pages using htaccess. This Tutorial shows how to make your own custom 404 pages.

Edited: 2015-12-04 12:10

htaccess custom error pages can be made using the ErrorDocument instruction.

Custom Error pages is useful when you don't want to lose traffic, from deleted or moved pages. Directing your users to either an internal 404 error page, or to the new location of the requested page, will usually hold on to them.

The below are is a list of response codes, that you can create a custom error page for.

  1. 400 Bad Request
  2. 401 Unauthorized
  3. 403 Forbidden
  4. 404 Not Found
  5. 500 Internal Server Error

Custom 404 Example

ErrorDocument 404 /404.html

The above example is setting a custom error page for 404 errors, the last part is the Root-Relative path to the error page.

Internet Explore and Browser add-ons

Internet Explore is known to replace the custom error page with its own error page, however this behavior only seam to occur when the page is below 512 bytes.

Some browser add-ons are also known to act in similar ways, so it would be a good idea to insure that the page is bigger then the 512 bytes.

See also

  1. HTTP Response Codes – A list of HTTP response codes.
  2. Creating a Custom Error Page – How to make the error page itself