Custom Error Pages without Cpanel Print

  • 23

If you're looking to create custom error pages the old fashioned way (editing the .htaccess file yourself), look no further. To do so you must first edit an .htaccess file in your public_html directory so that it has the following lines in it:

  • ErrorDocument 404 /myerrors/404.html
  • ErrorDocument 403 /myerrors/403.html
  • ErrorDocument 500 /myerrors/500.html

To explain what each part is we'll cut it up:

ErrorDocument - the command that tells apache that this is the error document to use for this directory and all directories under it unless a directory under it specifies otherwise.

404 (403 and 500) - The error code that states which error this document is to be called for.

/myerrors/404.html (403.html and 500.html) - the document that is to be used if this error should arise. In this case the error documents are located within the /public_html/myerrors/ directory. Please note that you need the / at the beginning so that apache (the web server) knows to start at /public_html/ .With the above used document location, the url remains the same, but the error page is shown. If you wish to have it so the url changes to that of the error page then simply turn it into a url. The example below shows how to do this for the 404 (file not found) error:

ErrorDocument 404

Should you notice that after doing this, your error page doesn't come up, check spelling, capitalization and the path or url of the error document to make sure it's correct. If it is, then try adding more content to the error page. Some browsers are set so that if there isn't enough content in the error page, they use their own default error page.

Was this answer helpful?

« Back

Powered by WHMCompleteSolution