Forum Moderators: phranque

Message Too Old, No Replies

404 Error reporting

Getting the page to report the error

         

EBear

7:40 pm on Mar 18, 2004 (gmt 0)

10+ Year Member



I like the power SSI gives you to do simple things without scripting. That gave me the idea to do the following on my 404 page. It uses Matt Wright's FormMail (I use the NMS version), but could be adapted for any mailform script. It will send you an email (almost) every time a 404 page is encountered by a real user (but not a bot or virus).



<H1>Error 404 - Page Not Found</H1>

<p>Sorry, you seem to have been misdirected to a page that no longer exists. Please click on the button below. It will bring you to our home page and send us a report of the error.</p>
<center>
<form name="404" action="http://www.yoursite.com/cgi-bin/formmail.pl" method="post">
<input name=recipient type=hidden value="you@yoursite.com">
<input name=realname type=hidden value="My Web Site">
<input name=subject type=hidden value="Missing Link Report">
<input name=redirect type=hidden value="http://www.yoursite.com/">
<input name="Failed_link_on_page" type=hidden value="<!--#echo var="HTTP_REFERER"-->">
<script language="javascript" type="text/javascript">
<!--
document.write('<input name="The_page_sought_was" type=hidden value="');
document.write(location.href);
document.write('">')
-->
</script>
<input type=submit value="Visit our Home Page">
</form></center>


I couldn't find a way in SSI to show the requested URL, rather than the one served (404 page). I prefer the SSI version of capturing the referrer to a Javascript history.back because it works even if the link is opened in a new window.