Looking for scripts to filter 404 traffic

Panky's picture

She has: 14 posts

Joined: Mar 2003

Are there any scripts available to filter 404 traffic? I prefer not to do this with .htaccess, which was why I was wondering if any scripts are available.

Thanks!

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

How do you want to filter it? Do you mean redirect?

Panky's picture

She has: 14 posts

Joined: Mar 2003

Basically redirect it, yes. I would like to be able to control various places 404 traffic could be redirected too within my own network of sites. I know that this can be done using .htaccess and custom pages, the problem is, I would prefer if my .htaccess file didn't become the size of a mini novel.

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

ErrorDocument 404 /errors/404.html'

...hardly a novel. Cool

Panky's picture

She has: 14 posts

Joined: Mar 2003

Thanks, but not what I was looking for. This links it back to a central 404 page. I'm looking for a way to funnel my 404 traffic to specific, targeted areas within my own network of sites. Not back to one custom 404 page.

Yes, I could build custom 404 pages and control this using .htaccess, but I would end up with quite a large list of custom 404 pages listed in my .htaccess file. I was wondering if an option was available to do this outside of the use of an .htaccess file. I would prefer a script do all the work and not an .htaccess file, if possible.

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

What criteria are you going to use to filter the traffic?

Panky's picture

She has: 14 posts

Joined: Mar 2003

Some ideas were to filter using

    country
    broken image 404
    allowing 404 traffic to be scattered amongst various sites within a network based on percentages. Lets say a site has 200,000 in 404 traffic. A certain percentage can be delegated to go to one particular spot. Then another chunk goes to another spot, and so on.
pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

Make this script your error page, and it will go to random places as specified in the array.

<?php
    $redirect_links
= array('www.google.com',
                                   
'www.yahoo.com',
                                   
'www.ask.com',
                                   
'www.ebay.com');
                                   
   
$max = count($redirect_links) - 1;
   
$random = rand(0, $max);
   
   
header('Location: <a href="http://'" title="http://'">http://'</a> . $redirect_links[$random]);
?>
'

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

You'll actually still need to funnel back to one central 404 page. However, that page will be a script that then redirects based on a variety of things.

The sample script they give on this page might be a good starting point:

http://www.web-goddess.org/phphelp/custom404.php

Panky's picture

She has: 14 posts

Joined: Mar 2003

Thank you. Your help is greatly appreciated! Smiling

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.