Knowledgebase: Site Functions
Use Custom Error Pages
Posted by on 27 February 2014 06:05 AM

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. Either way, please contact us immediately so we can diagnose the problem and assist you further.

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

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)

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

 

Servers Errors

500 - Internal Server Error

501 - Not Implemented

502 - Bad Gateway 

503 - Service Unavailable

504 - Gateway Timeout

505 - HTTP Version Not Supported

If you need any assistance with this, please do not hesitate to get in touch with our support team! We’re here to help.

(2 vote(s))
This article was helpful
This article was not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
Help Desk Software by Kayako fusion