Been working on this cloaking/re-directing script for Affiliate marketing purposes. I can't quite get it to work. I want to check the referrer domain that has gotten to my site. If it is a certain domain I want to display a page on my domain, and if it is any other referrer domain I want to re-direct to my affiliate link. Please help! This is what mydomain.com/index.php looks like: <?php if(stristr($_SERVER[’HTTP_REFERER’],â€referrerdomain.com/â€)==FALSE) { header( 'Location: http://affiliatelink.com' ) ; } else { header( 'Location: http://www.mydomain.com/signup.html' ) ; } ?> PHP: These are the errors I'm getting: Warning: Division by zero in /home2/...../public_html/mydomain/index.php on line 3 Warning: Cannot modify header information - headers already sent by (output started at /home2/...../public_html/mydomain/index.php:3) in /home2/...../public_html/mydomain/index.php on line 13 Any help is greatly appreciated!!!
Try this. <?php if(stristr($_SERVER['HTTP_REFERER'],"referrerdomain.com/")==FALSE) { header( 'Location: http://affiliatelink.com' ) ; } else { header( 'Location: http://www.mydomain.com/signup.html' ) ; } ?> PHP: Notice your double quote ( " ) became ( †) and also the single quote is having the same problem.
Your first if statement is also wrong. As stristr returns a pointer, you have to use three = instead of two. Like: <?php if(stristr($_SERVER['HTTP_REFERER'],"referrerdomain.com/") === FALSE) { header( 'Location: http://affiliatelink.com' ) ; } else { header( 'Location: http://www.mydomain.com/signup.html' ) ; } ?> PHP:
Or here is the simplest example <?php if (stristr($_SERVER['HTTP_REFERER'], 'google.com')) { echo 'You are from Google'; } else { echo 'You are not from Google'; } ?> PHP: