![]() |
123Webmaster.com
:
Onsite :
Building
Create a "Close Window" Button by Candice Pardue http://www.webmastercourse.com |
| Advanced 404 Pages
In a previous article, I
discussed the advantages of using a customized 404 error page on your site
and gave instructions on how to create one. As I explained back then, these
pages are highly useful because they enable you to benefit from traffic
that would otherwise be lost. They however do have one dark side that can
make maintaining your site significantly more difficult
What is this problem I'm talking about? Well, it is quite simple. Usually when a server encounters a 404 error, it records the details about the event into its log file. Should you suddenly notice that the log shows multiple 404 errors due to a page named "abutme.html" not being found, you can deduct that you've probably accidentally linked to "abutme.html" somewhere on your pages instead of using the correct filename "aboutme.html". As you can see from the above, the functionality offered by log files makes them a great help in tracking down such simple mistakes and enables you to keep your site relatively free of in-site broken links. However, if you happen to
have replaced the standard 404 error with your own HTML 404 error page,
you can't utilize this useful feature. Yes, you will still see that a 404
error has occurred,
All hope is not lost After reading the above,
you must be feeling pretty down. I sure know I did after having installed
my own 404 page only to notice that I had corrected one problem, but caused
another one while
Without further ado, let's
roll up our sleeves and get to work. The first thing you will need is a
CGI script that will log the errors and let you know about them. There
are several ones out there that you can use, but I personally prefer Matrix
Vault's free 404 Helper that can be found at
Before you start editing
the file, you'll need to know where your host has installed the Perl interpreter
and Sendmail. Once you have figured it out, check if the paths used in
the CGI script
After you have made sure
that the paths are correct, modify the rest of the script to suit your
needs. Be sure to replace the E-mail address in the $email field with the
one you want the
You're now done with the
CGI script. Save it as "404helper.cgi", without the quotes of course. However,
there's still work to be done, so take a deep breath and prepare yourself
for the next
Editing your custom 404 page and .htaccess file Just having the script will not be enough. In order for it to work, it has to be executed when an error is encountered. This is the part where the SSI's step into the picture. Open up your 404 error page in a text editor and add the following line into it: <!--#exec cgi="/your_CGI_directory/404helper.cgi"--> Because the script prints
out a few rows of HTML after it has been run, the best place for that line
is at the bottom of your 404 error page, but before the </BODY> tag.
After everything is safely in place, simply save the file, but instead
of ending it with the usual ".htm" or ".html", use ".shtml". Do not forget
to do this, as the SSI tag might not work if you fail to use the
Finally, you will have to
edit the .htaccess file you created
Options Includes ExecCGI
The new lines will enable
Server Side Includes and CGI so that
Upload, set permissions and
launch!
Connect to your host with
an FTP program and upload the .shtml
Everything is now uploaded
and all that remains is to set
First, navigate to the directory
where you've uploaded the CGI
That's it. The work is finally
done and you can now enjoy the
|