If Referring URL = X Then Redirect Here, If Y Then Redirect There???

Here you go:

PHP:
<?

$referer = $_SERVER['HTTP_REFERER'];
if($referer == "http://www.blackhatworld.com")//the referer you want to base your redirects on
    {
        header("location:http://www.google.com");//if condition is true
    }
else
    {
        header("location:http://www.yahoo.com");//if condition is false
    }

?>
 
Thanks a lot, Im using this one now:

PHP:
<?php

$match = false;
$sites = array("blackhatsite.com");

if(strlen($_SERVER['HTTP_REFERER']))
{
    $referer = parse_url($_SERVER['HTTP_REFERER']);
           
    $referer['host'] = str_replace("www.", "", strtolower($referer['host']));

    $match = in_array($referer['host'], $sites);
}

if($match)
{

?>
<?php
 echo '<meta http-equiv="refresh" content="0;url=http://www.yoursite.com/affiliateoffer.php">';
 ?>
<?php
}
else
{
?>
<?php
 echo '<meta http-equiv="refresh" content="0;url=http://www.homepage.com/">';
?>
<?php
}
?>

Probably a bit messy but it works lol
 
Thanks a lot, Im using this one now:

PHP:
<?php

$match = false;
$sites = array("blackhatsite.com");

if(strlen($_SERVER['HTTP_REFERER']))
{
    $referer = parse_url($_SERVER['HTTP_REFERER']);
           
    $referer['host'] = str_replace("www.", "", strtolower($referer['host']));

    $match = in_array($referer['host'], $sites);
}

if($match)
{

?>
<?php
 echo '<meta http-equiv="refresh" content="0;url=http://www.yoursite.com/affiliateoffer.php">';
 ?>
<?php
}
else
{
?>
<?php
 echo '<meta http-equiv="refresh" content="0;url=http://www.homepage.com/">';
?>
<?php
}
?>

Probably a bit messy but it works lol

Lol, Array for 1 value ^^ Not really needed.

Still, If it aint broke dont fix it
 
Yeah, I used it from a site that incorporated 2 referring URL's, do you know how I could switch it back to one? Or would you recommend the first PHP script that you posted here?
 
Hmm from what I see both scripts will do pretty much the same thing. But you script seem way to completed than it should be. So just use mind you will do find. Since you only have 1 value.
 
Last edited:
Thanks for the input Gen, could you help me out for a few mins at some point just to determine the referring URL on an iFrame script I have made and to see if you can find the affiliate link :p
 
Thanks for the input Gen, could you help me out for a few mins at some point just to determine the referring URL on an iFrame script I have made and to see if you can find the affiliate link :p

Do you need to see the referer?
If so, in your iframe page, add

PHP:
<?php
echo $_SERVER['HTTP_REFERER'];
?>

Yeah, I used it from a site that incorporated 2 referring URL's, do you know how I could switch it back to one? Or would you recommend the first PHP script that you posted here?

As for this, You can use

PHP:
<?php

if($_SERVER['HTTP_REFERER'] == "http://site url")
{
       Header ("Location: http://goherewatever/");
} else {
       Header ("Location: http://gohereinsteadcom/");
}

?>
 
I always use the switch case in PHP - beats a shed load of IF statements....but that array is isn't a bad idea as well....
 
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock