seomoz – PHP Reference Book Blog https://phpreferencebook.com/ PHP Reference: Beginner to Intermediate PHP5 Sun, 01 Oct 2017 17:21:19 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.13 SEOMoz – Third-Party Affiliate Programs https://phpreferencebook.com/misc/roll-your-own-affiliate-program/ Thu, 29 Oct 2009 23:45:16 +0000 https://phpreferencebook.com/?p=320 Continue reading SEOMoz – Third-Party Affiliate Programs]]> The following is a translation of ASP code to PHP for the following SEOMoz post:
Third-Party Affiliate Programs: Roll Your Own Instead

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
$AffiliateID = trim($_GET['affid']);
 
$CanonicalURL = $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'];
 
if (strlen($AffiliateID) > 0) {
	$CanonicalURL = str_replace("&affid=" . $AffiliateID,"",$CanonicalURL);
	$CanonicalURL = str_replace("&affid=" . $AffiliateID,"",$CanonicalURL);
 
	setcookie("AffiliateID",$AffiliateID,time()+60*60*24*90);
}
?>
 
...
 
<link rel="canonical" href="<?php echo $CanonicalURL; ?>" />
]]>