Looking for a php script which redirects all hits from referres but one

peetu69

Junior Member
Joined
Dec 7, 2010
Messages
193
Reaction score
133
Hello,

im loooking for a simple php script, which redirects all visits/hits from ALL referrers but one.

so basically in pseudo code it would look like this:

if (ref !=X){
redirect visitor to page xyz
}

i have no idea from php and only basic knowledge in programming from my studies.

Can anyone experienced help me?

Thanks :)
 
PHP:
$ref=isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$target_url = "http://www.example.com/page3";
$src="mydomain.com";
if ($ref !== $src) {
  header('Location: '.$target_url);
}
 
hey, that looks great!

i think it works, will try it now, thanks a lot!
 
Back
Top