JavaScript Editor Ajax software     Free javascripts 



Main Page

Redirecting Parameterized Affiliate URLs
It is also possible to use parameterized affiliate URLs, so long as the URLs are redirected to the “main”
URL after setting a cookie or session variable for your reference. This section presents two examples,
implementing them step-by-step in exercises.
One common theme in these presented solutions is that when a URL containing an affiliate ID is requested,
you retain the affiliate ID somewhere else, and then do a 301 redirect to the URL without the affiliate infor-
mation. The examples use the visitor ’s session to store the affiliate ID, but you may choose to use cookies
instead.
In Chapter 4 you learned that the 301 status code means “Moved permanently,” so the page you redi-
rect to is interpreted as the new permanent location of the requested page. This eliminates any potential
duplicate content problems.
Example #1
This example assumes that you have affiliate URLs that look like
http://seophp.example.com/
Products/SEO-Toolbox-C6/Link-Juice-P31.html?aff_id=987
. The URL you’re finally redirect
-
ing to is
http://seophp.example.com/Products/SEO-Toolbox-C6/Link-Juice-P31.html
.
Redirecting Keyword-Rich Affiliate URLs
1.
Open
.htaccess
and find the line that rewrites keyword-rich product URLs:
# Rewrite keyword-rich URLs
RewriteRule ^Products/.*-C([0-9]+)/.*-P([0-9]+)\.html$
i
/product.php?category_id=$1&product_id=$2 [L]
Modify this line by adding this bit to its end, like this:
# Rewrite keyword-rich URLs
RewriteRule ^Products/.*-C([0-9]+)/.*-P([0-9]+)\.html$
i
/product.php?category_id=$1&product_id=$2
&%{QUERY_STRING}
[L]
2.
Modify
product.php
like this:
<?php
// load library that handles redirects
require_once ‘include/url_redirect.inc.php’;
// start PHP session
session_start();
// save affiliate ID
if (isset($_REQUEST[‘aff_id’]))
{
$_SESSION[‘aff_id’] = $_REQUEST[‘aff_id’];
}
// redirect requests proper keyword-rich URLs when not already there
fix_category_product_url();
109
Chapter 5: Duplicate Content
c05.qxd:c05 10:41 109


JavaScript Editor Ajax software     Free javascripts