www.webdeveloper.com
Results 1 to 4 of 4

Thread: Method for finding 404 redirects...

  1. #1
    Join Date
    Aug 2007
    Location
    New Jersey, US
    Posts
    1,779

    Method for finding 404 redirects...

    Hey guys,

    This is probably a stupid way of tracking 404s, but I've recently decided to receive emails with referral URL every time my 404 page was triggered.

    I've added this code to my 404 page:
    PHP Code:
    <?php
        $previousPage 
    $_SERVER["HTTP_REFERER"];
        
    mail("me@domain.com""404 Error""Error 400 from " $previousPage)
    ?>
    Normally, I'd get an email that says:
    Error 400 from http://www.domain.com/page-with-broken-link.php

    But I've been getting many emails just just say "Error 400 from" with no url. Does anyone know why this is?

    I'm thinking that it could be search engine bots/spiders, but I'm not sure.

    Is this a stupid way to try to track down broken links? I was hoping that I'd find broken external links. I'm sure that there's better ways to do this. Do you know of any. I do use Analytics, if that can help.

    Thanks!

  2. #2
    Join Date
    Jul 2009
    Location
    Falls Church, Va.
    Posts
    780
    'HTTP_REFERER'

    The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

    A few alternative solutions to consider:

    Products like Webalizer and AWStats which get the 404 failed url from your web server log directly can email you reports. For example, Webalizer an extension called "Xtended" that generates additional stats for error 404's in a more detailed report format that can be friendly emailed/printed. This is a consolidated report which you might schedule periodically for delivery at non-peak times to reduce server load (and maintain your sanity which you might lose as a result of processing all those emails using the method you use now.)

    Google Analytics also has a means to track 404's so they show up in your reports, which is more real time and also just as friendly looking.

    -jim

  3. #3
    Join Date
    Aug 2007
    Location
    New Jersey, US
    Posts
    1,779
    Nice, thanks Jim.

    I already use Analytics, so I'll check out their solution to 404 error tracking.
    I've removed the mail function, as that we getting annoying...

  4. #4
    Join Date
    Jul 2009
    Location
    Falls Church, Va.
    Posts
    780
    Cheers.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles