Forum Moderators: coopster
$_SERVER['HTTP_REFERER'] [ca.php.net]
though they are not always present. You can then compare the referer with a list of referers that need to be redirected and redirect them using header [ca.php.net]
www.abc*.com
www.blahblah.com
www.ufks*.*
and all of them will be redirected to www.mydomain.com/forbidden.html
Is that possible, written once in just a simple code like the robots.txt which only needs user-agent and dissalow syntax?
Thanks.
JohnHeart
but
you could have the script do somthing like
1. load domains from textfile into array
2. compare with the refere if available
3. redirect if needed
I do see the issue that if the referer file gets too long it could be a bit slow but it should be a fine approach.
<?php
#THIS ARRAY CAN BE IN A SEPARATE FILE AND INCLUDED
$badapples=array("www.abc*.com","www.blahblah.com","www.ufks*.*");
#GRAB THE REFERRER
$checkfruit=$_SERVER['HTTP_REFERER'];
#RUN THROUGH BADAPPLES AND SEE IF THEY'RE IN REFERRER
foreach ($badapples as $kick) {
if (eregi($kick,$checkfruit)) {
#IF FOUND, KICK 'EM OVER TO THE NAUGHTY PAGE
header("Location: www.mydomain.com/forbidden.html");
}
}
?>
Have fun!
[edited by: jatar_k at 4:57 pm (utc) on May 11, 2004]
[edit reason] member request [/edit]
#RUN THROUGH BADAPPLES AND SEE IF THEY'RE IN REFERRER
foreach ($badapples as $kick) {
if (eregi($kick,$checkfruit)) {
#IF FOUND, KICK 'EM OVER TO THE NAUGHTY PAGE
header("Location: www.mydomain.com/forbidden.html");
#ADD AN EXIT STATEMENT TO STOP RUNNING THROUGH THE ARRAY
exit;
}
}