Redirect script not working – can someone please help!

streetjammer

BANNED
Joined
Sep 25, 2008
Messages
115
Reaction score
5
Hi Guys!

I am trying to build a small script that can do some redirect for me. But after some unsuccessful hours searching for something like it I gave up :(

Here is what i am trying to make:

If and only if visitors come from: example1.com --> then random auto redirect to a list of web pages. (I have seen this before in JS)

If visitors come from any other url than example1.com --> then auto redirect to example2.com

I then need the referrer url for the first scenario to be example3.com and the second scenario to be example4.com

Can someone please help a friend in need?

Thanks in advance :D
 
Last edited:
I kinda lost you at the end but, this should be more or less what youre looking for.. you may have to play with it i didnt test it.
Code:
<?PHP 
srand((float) microtime() * 10000000);
$sites=array("something.com","something.com","something.com","sopmething.com");
$rand_sites = array_rand($sites, 1);
$referer=$_SERVER['HTTP_REFERER'];

if($referer=='example1.com'){

// this will redirect them to a random site
// defined in $sites
header('Location: '.$input[$rand_sites[0]]);

} elseif ($referer!='example1.com'){


header('Location: example4iguess.com');

}
 
do you own example 3 and 4? or are you trying to mask the true refering url?
 
Thanks for sharing the code bosshog :)
I don't know if it's me but I can't get the script to redirect to: example1.com - its redirecting to example4iguess.com instead??
nerdmoney - Yes I own example 3 + 4
 
It redirects to example4 if the referer is not example1
 
Oh i get it now, you want to set the referers and check them as well + redirect etc?
 
Let me try to explain it in a different way.

If user comes from site "A" the user will be redirected randomly to site(S) "B" (Must be multiple) --> Displaying Site "C" as referer in log files

If the user don't come from site "A" the user will be redirected randomly to site(S) "D" (Must be multiple) --> Displaying referer(S) in log files randomly (Must be multiple)

Is it possible to make? Or is it only me that need such strange stuff?
 
Its possible to write that, but you need to own the domains whos referers you want to use.
 
Back
Top