Redirect based on referrer?

icekold

Newbie
Joined
Nov 27, 2007
Messages
18
Reaction score
3
Hey guys...

maybe someone here can help me out. I need some code to redirect visitors based on the referrer. Basically i want to send traffic with a referrer to page1.php, and blank referrer traffic to page2.php

So if someone clicks my link, I want them to go to my landing page, but if they access direct ie: type in url, send them to an error page.

Probably easy, but I suck at this coding stuff...lol. Thanks
 
PHP:
<?php
	$referer = $_SERVER['HTTP_REFERER'];
	if($referer == "http://www.yoursite.com/referrer-you-want-it-to-be.php")
	{
		echo '<meta http-equiv="refresh" content="0;url=http://www.yoursite.com/page1.php">';
	}
	else
	{
		echo '<meta http-equiv="refresh" content="0;url=http://www.youfail.org/">';	
	}
?>
 
just another alternative:

Code:
<?php

$referrer = $_SERVER['HTTP_REFERER'];

if($referrer == ""){
    header("HTTP/1.1 404 Not Found");
}

?>
 
Thanks a bunch guys...

Tried each on seperate campaigns, and they both work great. Thanks for helping a newbie out. Pushed the little button for ya too!
 
Back
Top