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

oni3350

Senior Member
Joined
Sep 24, 2008
Messages
874
Reaction score
564
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.
 
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.
 
That 's the way to go, as thedelimiter suggested. You could easily "rewrite" the anchor text too this way.
 
Back
Top