ams007 Posted June 6, 2008 Share Posted June 6, 2008 Good Morning, I am sending traffic to a page which meta-refreshes to an affiliate program. I would like to use php to alternate the redirect between 2 or 3 affiliate links so I can see which converts better. I know it should be rather simple for anybody who knows php, but I am just a beginner. Please help. Thanks, AMSCS Link to comment https://forums.phpfreaks.com/topic/108984-php-redirect-to-alternate-affiliate-links/ Share on other sites More sharing options...
dmccabe Posted June 6, 2008 Share Posted June 6, 2008 to do the redirect you can use: header("location:url1.php"); Where url1.php is the page your re-directing to. Link to comment https://forums.phpfreaks.com/topic/108984-php-redirect-to-alternate-affiliate-links/#findComment-559102 Share on other sites More sharing options...
jonsjava Posted June 6, 2008 Share Posted June 6, 2008 <?php $links = array(); $links[] .= "http://first_link.com"; $links[] .= "http://second_link.com"; //and so on and so forth.... $last = count($links) - 1; $choice = rand(0, $last); header("location". $links[$choice]); ?> Link to comment https://forums.phpfreaks.com/topic/108984-php-redirect-to-alternate-affiliate-links/#findComment-559105 Share on other sites More sharing options...
ams007 Posted June 6, 2008 Author Share Posted June 6, 2008 <?php $links = array(); $links[] .= "http://first_link.com"; $links[] .= "http://second_link.com"; //and so on and so forth.... $last = count($links) - 1; $choice = rand(0, $last); header("location". $links[$choice]); ?> Looks great, tried it, but all I get is a blank html page. Please relook at the code and see if it's correct. Thanks, Al Soto Link to comment https://forums.phpfreaks.com/topic/108984-php-redirect-to-alternate-affiliate-links/#findComment-559209 Share on other sites More sharing options...
jonsjava Posted June 6, 2008 Share Posted June 6, 2008 forgot a ":" <?php $links = array(); $links[] .= "http://first_link.com"; $links[] .= "http://second_link.com"; //and so on and so forth.... $last = count($links) - 1; $choice = rand(0, $last); header("location:". $links[$choice]); ?> Link to comment https://forums.phpfreaks.com/topic/108984-php-redirect-to-alternate-affiliate-links/#findComment-559214 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.