Log or e-mail 404 errors code

Discussion in 'PHP' started by xtreme fever, Mar 19, 2008.

  1. #1
    Hello,

    I'm trying to find code where I can track 404 errors either by logging to a file or by e-mailing me the error. This should include the referring info etc...

    Thanks
     
    xtreme fever, Mar 19, 2008 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Check your server log?
     
    nico_swd, Mar 19, 2008 IP
  3. xtreme fever

    xtreme fever Active Member

    Messages:
    472
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    95
    #3
    ha, without checking server log
     
    xtreme fever, Mar 19, 2008 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Not sure why, though, but anyway.


    Check PHP's reserved variables. From there you can get the referrer, the IP, Request URI, etc...

    Then create a string with the variables and use either the mail() function to mail it to you, or the file_put_contents() function to save it locally.

    Oh yes, and use htaccess to create your custom 404 page which logs the stuff.
    
    ErrorDocument 404 /404.php
    
    Code (markup):
     
    nico_swd, Mar 19, 2008 IP
  5. xtreme fever

    xtreme fever Active Member

    Messages:
    472
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    95
    #5
    Thanks. I kept finding codes for wordpress. I'll see what I can string together.
     
    xtreme fever, Mar 19, 2008 IP