Loading...

Knowledge Base
Categories: , ,

Use Custom Error Pages

Did you find this article helpful?
Copy Link

 
* Your feedback is too short
Share

What is an error page?

We’ve all seen the dreaded error messages that are unfortunately a fact of the internet. If someone is browsing your website and clicks an invalid link they will likely be directed to a vague and boring 404 page… and that’s not ideal.
There could also be a few other reasons causing a 404 error which include:

  • Hotlinking issue - You may get a 404 error for images because you have Hot Link Protection enabled and the domain is not on the access list.
  • .htaccess issue - If you go to 'http://ip/~username/ ' and get a 404 error, you might have incorrect coding in your .htaccess file. We recommend renaming that file to '.htaccess-backup' and refreshing the site to see if anything changes.
  • Missing public_html folder - You may have also inadvertently deleted your 'public_html' folder, or the entire account may need to be recreated. 

Create a Custom Error Page

With just a little bit of work it’s very easy to create a custom 404 error page just like ours at http://asmallorange.com/404.

You will need two things to get started:

  • Custom 404 error page that you have designed
  • Little bit of code added to an .htaccess file that tells the server that you have a custom 404 page in place

You’ll need an .htaccess file to begin implementing your new 404 message.

If you already HAVE an .htaccess file in the public_html folder of your cPanel account, then simply add the text below to the top of the file and save it:

ErrorDocument 404 /404.html

Note: this is assuming that you have named your 404 error page ‘404.html’ and placed it inside the public_html folder. If you have not named it that way, make sure the code shown above reflects the proper name of your 404 file.

If you DO NOT already have an .htaccess file in the public_html folder then you’ll just need to create one:

  1. Open your favorite text editor (notepad, textedit).
  2. Save the file as .htaccess (yes, that ‘.’ at the beginning is supposed to be there).
  3. Once the file has been created add the code shown below to the file and save it again:

ErrorDocument 404 /404.html 

Note: this is assuming that you have named your 404 error page 404.html and placed it inside the public_html folder. If you have not named it that way, make sure the code shown above reflects the proper name of your 404 file.

Now, all that’s left to do is upload this file via either FTP or cPanel File Manager, and make sure that it’s in the 'public_html' folder of your cPanel account.

You’re not restricted to only having a custom 404 error page… there are several error codes that you can create custom pages for, including:

Client Request Errors
400 - Bad Request
401 - Authorization Required
403 - Forbidden
404 - Not Found
405 - Method Not Allowed
406 - Not Acceptable (encoding)
407 - Proxy Authentication Required
408 - Request Timed Out
409 - Conflicting Request
410 - Gone
411 - Content Length Required
412 - Precondition Failed
413 - Request Entity Too Long
414 - Request URI Too Long
415 - Unsupported Media Type

Server Errors
500 - Internal Server Error
501 - Not Implemented
502 - Bad Gateway
503 - Service Unavailable
504 - Gateway Timeout
505 - HTTP Version Not Supported
 

Did you find this article helpful?
Copy Link

 
* Your feedback is too short

Loading...