404 Custom Error Page

In cPanel, the Error Pages function allows you to modify the different html pages that a user will see when an error is registered on your site. The most common being the famous 404 Page Not Found error that you get when a page does not exist. This tutorial will show you how to setup a proper 404 Error page, so that visitors to your site will hopefully find what they are looking for.

cPanel lets you save the custom 404 Error page as anything you want, but the default name for it is 404.shtml. It is best to go ahead and code an html file and then upload it to your public_html folder as 404.shtml. You can then view and edit this file by going to cPanel: Error Pages.

As to what to include in your 404 Page, you can use our own WebKeyDesign 404 Page as an example. The basic things to include would be:

1. Your site logo, with a link to your home page.

2. An explanation for the error, like “Sorry the page so and so cannot be found on our site”. If you insert the code <!–#echo var=”REQUEST_URI” –> into your html, this will display the url that the browser requested. On our 404 page, we include the code <!–#echo var=”HTTP_REFERER” –> so that the person knows who referred them to the incorrect page.

cPanel offers the following variables in Error Pages:

  • Referring URL: Displays the URL that referred a user to the page.
  • Visitor’s IP Address: Displays the users IP address.
  • Requested URL: Displays the URL requested by the user.
  • Server Name: Returns the servers name or websites URL.
  • Visitor’s Browser: Displays information about the user’s browser.
  • Redirect Status Code: Displays the error code associated with the error.

3. A Default Page to your site is very helpful, for visitors to learn more about your site. Usually the default page should be a site map, an about page, or at least your home page.

4. Contact Information is essential. Some visitors will want to contact you, so include your contact page or email address for your site. The webmaster@mydomain.com is probably best to use if you are going to put an email address.

Other ideas for your 404 page:

The search box is a good idea. On our default page, we setup a form that simply searches our site through Google, but you could get more complicated, by including your own site’s search box and code. To implement a simple search box include the following form code:

<form action="http://www.google.com/search" name="searchbox"
  method="get" style="margin-left: 2em;" />
  <input type="hidden" name="hl" value="en" />
  <input type="hidden" name="ie" value="ISO-8859-1" />
  <input type="hidden" name="sitesearch" value="Yoursite.com" />
  <input maxlength="256" size="40" name="q" value="" />
  <input type="submit" value="Search" name="btnG"
    style="font-size:75%;" />
</form>

You will need to change the Yoursite.com to whatever your actual domain is of course.

Another good idea is a navigation bar for all of your site’s main pages.

One last thing to consider is that Internet Explorer will nto display any 404 Error page that is less than 512 bytes, which means your error page needs to be at least around 12 lines of code.

For more information visit some of these sites:

Filed under: cPanelTagged with: , , ,

3 Comments

  1. Avatar

    Or if you’re using WordPress, the theme you’re using could contain a custom 404.php page already. If it doesn’t, you could always use the instructions from the WordPress Codex to make one. The advantage to adding the404 page to our WordPress template is you’re more likely to remember to update the 404 page when you go to redesign your site.

  2. Avatar

    Thank you very much for such a helpful article. In fact I was troubled setting up error page and posted a question on frihost. One friend there gave me this link and I’m happy that this is a great article. Now I can update my custom error page.

    Thank you very much.


Add a Comment

Your email address will not be published. Required fields are marked *

Comment *
Name *
Email *
Website