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.

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.

http response codes

The below are a collection of error response codes, that you can create a custom 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 first defining the ErrorDocument, then the type of error, in this case for the 404 Not Found Error. Next it defines the location of the error page, in this case using a Root-Relative Path, you can use either Root-Relative or Absolute Paths.

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.

Post comment

Links that you insert are not nofollowed, but will be removed by admins if they are considered spam.

[url=Absolute URL for page]TITLE[/url]

You should insert code boxes around code examples, which will be automatically syntax highlighted.

[code1 html|css|javascript|php|sql]Your Code Here[/code1]

You may want to read our Privacy Policy before submitting your comment.