1. What is a custom error
page?
A custom error page is an error page you can make to look
like it "belongs" to your web site. If a visitor to your web
site types in the wrong URL (address), or enters the
incorrect information, you can have nice looking error pages
that can redirect them to another part of your website
instead having a visitor leave your site discouraged. With a
custom 404 page, you can add your logo to the page and also
redirect them back to the home page. For more information
about 404 pages
2. What kind of error pages can I
create?
- 400 Bad request -- This means that a request for
a URL has been made but the server is not configured or
capable of responding to it. This might be the case for URLs
that are handed-off to a servlet engine where no default
document or servlet is configured, or the HTTP request
method is not implemented.)
- 401 Authorization Required -- "Authorization is
required to view this page. You have not provided valid
username/password information." This means that the required
username and/or password was not properly entered to access
a password protected page or area of the web site space.
- 403 Forbidden -- "You are not allowed to access
this page." (This error refers to pages that the server is
finding, ie. they do exist, but the permissions on the file
are not sufficient to allow the webserver to "serve" the
page to any end user with or without a password. If you want
this page to be viewable by the user you must change
permissions on the file.)
- 404 Page Not Found -- "The requested URL could
not be found on this site." Probably the most common error
message, this means the page as it was entered in the URL
does not exist on the server. This is usually caused by
someone incorrectly typing the URL, or by the web master
renaming or moving an existing page to a different
directory. (Old links may continue to show up in Search
Engines for months, and if pages have been deleted or moved,
any attempts to access the old links will result in a 404
Page Not Found error unless you have a redirect set up from
the old page to the new page.)
- 500 Internal Server Error -- "The server
encountered an internal error or misconfiguration and was
unable to complete your request. Please contact the server
administrator and inform them of the time the error
occurred, and anything you might have done to produce this
error." (By the way this error is usually caused by a
misconfiguration in a script, so if you get this you will
should look at your error logs in your hosting account
cPanel to find out the cause.)
3. How can I make my own "error
pages"?
Create an html or shtml page that looks like and says
what you want it to. Click "Error Pages " icon. The process
is almost step-by-step and "almost" self-explanatory. Click
on whichever error page you want to customize. It will take
you to a big text box, copy the entire HTML code of the
custom error page you created and paste it all into the text
box, then click "Save". There are a few tricks to success
however:
- Make sure that everything in your page code uses the
entire url, including image sources. If you're using
stylesheets or JavaScripts, make sure that they also use
the entire url in the call:
<img
src="http://yourdomain.com/images/imagename.jpg">
instead of simply <img
src="images/imagename.jpg">, and
<script
language="JavaScript"
src="http://yourdomain.com/scriptdirectory/javascriptname.js"></script>
<link rel="stylesheet"
href="http://yourdomain.com/stylesheetname.css"
type="text/css">
and so on. Or you could simply
put your styles right into the body of the page, ditto
with the JS unless it's one that must be placed between
<head> and </head> tags.
- The code for the Error page must be at least 10Kb or
it won't display properly in Internet Explorer. It's just
one of IE's quirks. An easy workaround if you don't want
your error page to ramble on & on is to simply put a
bunch of other "stuff" within comment tags somewhere in
your page. That way it won't show up when displayed in a
browser. Comment tags are <!-- and -->, with the
<!-- placed before your comments and --> placed
after. Anything you have between these two tags will not
be displayed in a browser. Example:
<!-- This is a bunch of extra stuff I have
to write in order to make the code of this page large
enough for the custom error page to show up in Internet
Explorer. Thanks Bill Gates!! blah blah blah blah and on
and on until the page is long enough :-s -->
- In your cPanel when you select the Error Page you want
to edit, you will find above the edit text box several
buttons:
- Referring URL
- Visitor's IP address
- Requested URL
- Server Name
- User's Browser
- Status Code
These are things you can insert into the code of your
page to customize it even further. For example if you
choose "Requested URL", it will give you code to insert
into your page so that the URL requested by the visitor is
displayed on the page.
To the left of these buttons
is another button that says "Click to Insert". Now this is
a little misleading. When you click to insert, it will NOT
insert anything where you have your curser. I wish it did
but it won't; it's a cPanel quirk. It will instead insert
the code just after or just before any code you have
entered in the text box. The "inserted" bit of code will
look something like this: <!--#echo var="REQUEST_URI"
--> although the "REQUEST_URI" may be replaced by
something else depending on what you selected. Look for it
at the very beginning or very end of your pasted code and
then cut/paste it into the proper spot in your html
code.
- Make your custom error page/s interesting and helpful.
Give visitors information they can use to navigate your
site: Links, a menu, email address for help or support,
etc. A bit of humor can be fun too, if it fits in with
your site, by taking some of the edge off people's
frustration when they get an error page.
- And of course it would be best to coordinate your
error page/s with your site, at least to some extent.
As always, if you need any help at all, feel free to email
us at support@hostinpak.com or use the PHP Live button on the
left. |