1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How can I redirect direct linked affiliate links on my site?

Discussion in 'General Programming Chat' started by oni3350, Dec 1, 2011.

  1. oni3350

    oni3350 Regular Member

    Joined:
    Sep 24, 2008
    Messages:
    361
    Likes Received:
    194
    Occupation:
    Internet Marketer/ Black Hatter
    Location:
    Perth, Western Australia
    Home Page:
    I know, i should have been setting it up differently, but over the past year ive been creating posts on my blog and direct linking to an affiliate site with my affiliate link.

    Now the site isnt converting as great and I want to try and change the destination to another program without having to manually go through each post and change it all.

    Im thinking it might be possible in httaccess to tell the server: "redirect all outgoing http://www.affiliatelink.com/blahblahblah?23458 links to X location" even if the link isnt pointing to a domain that I own, if you know what im saying.

    But im not sure how it can be done.
     
  2. thedelimiter

    thedelimiter Newbie

    Joined:
    Nov 11, 2011
    Messages:
    16
    Likes Received:
    8
    Location:
    Chicago
    Home Page:
    Pretty sure you can't use a rewrite rule to redirect for this. The request has to be one processed by your webserver.

    You can use some javascript. I'd use JQuery to match all links with href containing affiliate link, then add onclick handler to them, and change the document.location there.
     
  3. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,148
    That 's the way to go, as thedelimiter suggested. You could easily "rewrite" the anchor text too this way.