JavaScript Editor Ajax software     Free javascripts 



Main Page

Figure 5-3
4.
Load
http://seophp.example.com/aff_test.php?a=1&aff_id=34&b=2
, and expect to
be redirected to
http://localhost/seophp/aff_test.php?a=1&b=2
, with the affiliated ID
being retained, as shown in Figure 5-4.
Figure 5-4
Although you’ve written quite a bit of code, it’s pretty straightforward. There’s no URL rewriting involved,
so you’re working with plain-vanilla PHP scripts this time.
Your
aff_test.php
script starts by loading
url_utils.inc.php
and
config.inc.php
, and starting the
PHP session:
<?php
// include URL utils library
require_once ‘include/url_utils.inc.php’;
// load configuration script
require_once ‘include/config.inc.php’;
// start PHP session
session_start();
Then you verify if the
aff_id
query string parameter is present. In case it is, you save its value to the user ’s
session, and redirect to a version of the URL that doesn’t contain
aff_id
. The
remove_query_param()
function from the URL utils library is very handy, because it correctly preserves all existing parameters:
// redirect affiliate links
if (isset($_REQUEST[‘aff_id’]))
114
Chapter 5: Duplicate Content
c05.qxd:c05 10:41 114


JavaScript Editor Ajax software     Free javascripts