Turn a normal link into an affiliate link using PHP

Discussion in 'Affiliate Programs' started by athlonin, Dec 25, 2005.

  1. #1
    Hi all,

    I am interested to learn how you can redirect all links through a php script to add an affiliate id onto the end (if you have one for that site).

    So for instance, a user submits a post linking to www.bestbuy.com/productA. The link is fed through a php script which appends my BestBuy affliate id onto the link.

    All links on the site would feed through the PHP script, but only links to sites that I have an affiliate account with would change.

    Is this possible? I think that fatwallet.com does something to this effect.

    Example:
    Link submitted by user: http://www.amazon.com/exec/obidos/ASIN/B000BNKXEE/

    Link visible on fatwallet.com: http://www.fatwallet.com/redirect/bounce.php?afsrc=1&url=http://www.amazon.com/exec/obidos/ASIN/B000BNKXEE/qid=852619/ref=nosim/fatwalletcom/v=glance&s=apparel/103-9687342-2089457

    Destination link: http://www.amazon.com/exec/obidos/ASIN/B000BNKXEE/qid%3D852619/ref%3Dnosim/fatwalletcom/v%3Dglance%26s%3Dapparel/103-7057263-3387836
     
    athlonin, Dec 25, 2005 IP
  2. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #2
    maybe a mod-rewrite with page.html fed to the php?

    .htaccess in products folder
    
    RewriteEngine on
    RewriteBase /products
    RewriteRule ^item-([^.]+).html$ index.php?i=$1[L]
    
    PHP:

    index.php in products folder
    
    $out = '';
    switch ($_REQUEST['i'])
    {
        case "a":
            $out = "http://www.example.com/affiliate-info-a";
            break;
        case "b":
            $out = "http://www.example.com/affiliate-info-b";
            break;
    }
    
    if($out != '')
        header("Location: $out");    
    
    PHP:
    URL for product a == http://www.example.com/products/item-a.html

    Just musing, I didn't try to test this.
     
    noppid, Dec 25, 2005 IP
  3. Dakait

    Dakait Banned

    Messages:
    287
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Good Post. :)
     
    Dakait, Dec 26, 2005 IP