Page 1 of 1

404 error page

Posted: Thu Aug 07, 2003 11:09 pm
by sanjayk
I can assign a page for 404 errors on my web site. I want to make this page a .php page and want it to log exact error URL to some file. I will appreciate some hints. Thanks.

Posted: Thu Aug 07, 2003 11:47 pm
by dataangel
You can get the error URL by using $PHP_SELF

It automatically stores the path to whatever page is being viewed.

Posted: Fri Aug 08, 2003 12:59 pm
by macewan
create a .htaccess file with this:
ErrorDocument 404 404.php

create the 404.php with this in it:

<?php
$ip = getenv ("REMOTE_ADDR");
$requri = getenv ("REQUEST_URI");
$servname = getenv ("SERVER_NAME");
$combine = $ip . " tried to load " . $servname . $requri ;
$httpref = getenv ("HTTP_REFERER");
$httpagent = getenv ("HTTP_USER_AGENT");
$today = date("D M j Y g:i:s a T");
$note = "some more text that can be used" ;
$message = "$today \n
<br>
$combine <br> \n
User Agent = $httpagent \n
<h2> $note </h2>\n
<br> $httpref ";
$message2 = "$today \n
$combine \n
User Agent = $httpagent \n
$note \n
$httpref ";
$to = "you@yourwebsite.com";
$subject = "yourwebsite.com Error Page";
$from = "From: errorreport@yourwebsite.com\r\n";
mail($to, $subject, $message2, $from);
echo "
put your custome error in here.
" ;
?>


this will email you each time someone tries to access a missing page

Posted: Fri Aug 08, 2003 9:03 pm
by sanjayk
This is exactly what I was looking for. I appreciate it.

Thanks!
Sanjay

Posted: Mon Aug 11, 2003 7:52 pm
by macewan
=)