Custom Error Documents

Using your .htaccess file you can specify custom error documents that include the creation of dynamic "on the fly" linking. In the file itself you include these lines:

ErrorDocument 400 http://www.your_domain.com/cgi-bin/error.cgi
ErrorDocument 403 http://www.your_domain.com/cgi-bin/error.cgi
ErrorDocument 404 http://www.your_domain.com/cgi-bin/error.cgi
ErrorDocument 500 http://www.your_domain.com/cgi-bin/error.cgi

The CGI file looks like this:



           #!/usr/bin/perl

           print "Content-type: text/html\n\n;
           print "<HTML>\n<HEAD>\n<TITLE>Document Not Found</TITLE>\n</HEAD>\n";
           print "<BODY BGCOLOR=F00000>\n";
           print "<H1 ALIGN=center>Document Not Found</H1>\n";
           print "<P>The document you requested is no longer available at the \n";
           print "location that you specified. You can return to our \n";
           print "<A HREF=\"/index.html\">home page</A> or send email to the \n";
           print "<A HREF=\"mailto:yourname\@your_domain.com\">Site
           Administrator</A>. \n";
           print "</P>\n";
           print "</P>\n";

           if ($ENV{ ' HTTP_REFERER ' })  {
                $referrer = $ENV{ ' HTTP_REFERER ' };
                print "<P>You can also return to the page you came from:<BR>\n";
                print "<A HREF=\"$referrer\">$referrer</A></P>\n";
           }
           print "</BODY>\n</HTML>\n";
           

What this does, is it presents them with an error document and a link back to whatever page they were on, so they can make another choice. It does not matter what page they were on when they linked to the "file not found", they always get a link back to the page that referred them.

| Back to Article Index |

Copyright © All Rights Reserved. The information/images on this website
may not be reproduced or republished by anyone without permission.