cPanel Basics: How To Create Custom Error Pages

July 23rd, 2008 · 2 Comments

Error pages are web pages being served to the visitor when a problem occurs. These errors are identified by a numeric value usually from 400 to 500. The most well-known errors are probably “404 - Not Found” and “500 - Internal Server Error”.

Usually the default error pages simply display some basic information regarding the error that occured. But did you know that you can customize this? What if you could not only give it the look and feel of your website but also give the visitors some useful information to help them find what he wants?

There are various things you can do with error pages like logging detailed error information in a database, passing some data to a local search engine to help the visitor find what he’s looking for, etc. For instance, if a Google search result led to a 404 page on your website, you could grab the keywords searched and suggest related content to the visitor.

Most web control panels allow you to customize your website’s error pages but today we’ll focus on doing this with cPanel.

First start by clicking on the Error Pages icon from the Advanced panel (assuming you’re already logged in cPanel of course).

Next you will be prompted to select for which domain you want to modify the error pages. Select it and hit the Go button.

You must now select which error page you want to customize:

  • 400 - Bad Request: This occurs when the web server considers that the request made by the web browser is malformed.
  • 401 - Authorization required: The request received by the web server is correct but the needed authorization information has either not been sent or was incorrect.
  • 403 - Forbidden: The request sent by the web browser to the web server is correct but access to the resource was denied. For instance, it could be due to incorrect file permissions.
  • 404 - Wrong page: This happens when the requested document does not exist.
  • 500 - Internal Server Error: Your Web server encountered an unexpected condition that prevented it from fulfilling the request by the client.

For this tutorial, we’ll create a custom 404 error page since this error is probably the easiest one to provoke.

Note: if you are using a Wordpress blog, creating a custom 404 error has no effect since all requests made to the web server are parsed by Wordpress. Therefore, the 404 page are generated by the blog software itself. There might be some other web applications that behave like this too.

Click on the 404 link to create a custom error page. You will be brought with an online editor (a very basic editor, that is) to help you create your custom page. There are some buttons at the top what will help you insert some dynamic information.

Let’s create an error page with this content for example:

<p>Oops! The page you have requested cannot be found.</p>

<ul>
<li>Requested URL: <!--#echo var="REQUEST_URI" --></li>
<li>Your IP address: <!--#echo var="REMOTE_ADDR" --></li>
</ul>

Now save this file as 404.shtml and click on the Save button at the very bottom. Open your web browser to a web page that doesn’t exist on your website and you should get something like this:

You could also have saved the file with the .php extension so that it would’ve been processed as a PHP script but more on this in a future post!

Links

2 responses so far ↓

1. Response by : Anthony Damasco on Jul 23, 2008 at 2:48 pm

Thanks man, I never got around to learning this, do you know how to do it in plesk?

2. Response by : Stephane Brault on Jul 23, 2008 at 3:14 pm

Hi Anthony,

I will post a series of tutorials on Plesk very soon. Subscribe to my RSS feed to be notified.

http://www.feedburner.com/fb/a/emailverifySubmit?feedId=1480074

In fact, you more or less need a control panel to do this. Custom error pages can be specified in .htaccess (this is for Linux hosting of course).

http://www.thesitewizard.com/archive/custom404.shtml

Leave a Comment




Posted in Control Panels · Tutorials | 2 Comments

Dedicated Servers
 
VPS
Website Hosting
 

Recent Comments

Recent Webmasters

Hosting Type :
Monthly Price :
Storage :
Transfer :
Sort By :