How to Redirect Outbound Affiliate Links

Question: I wanted to link to your book from my site using an affiliate link, but will not be able to put affiliate links on my site, how do I link to pages on my site and have them jump to affiliate links?

Answer: Many affiliates link to and then redirect that location either using .htaccess or a PHP jump script. Some affiliates also block the directory of affiliate links using a robots.txt file.

The advantages of doing this are:

  • getting around publishing requirements that prevent you from posting affiliate links to your site

  • potentially shield some of your affiliate footprints from some information retrieval systems (although likely many of them will be able to understand your link relationships to some level based on surfing habits of your visitors). Some affiliates may also cloak their links to show engines links to well trusted sites, but that could be considered shady by some search engines
  • making it harder for newbies to see how to access the affiliate program that you are recommending or that the link is an affiliate link (some people also use a JavaScript scroll-over event that shows the end site URL to further cloak the affiliate relationship)
  • easily change what merchant or what merchant offer is associated with affiliate links throughout a site by changing the one .htaccess or php redirect file

A while ago NotSleepy guest posted about using .htaccess and redirects. You may want to use 302 instead of 301 redirects if you are using .htaccess for your redirects. Here is an easy to use PHP jump script if you would prefer to use that over .htaccess.

Published: November 30, 2006 by Aaron Wall in Q & A


July 6, 2007 - 12:28pm

Quick question I use a php redirect for my affiliate links. What other things should I do to prevent being penalized from Google?

I have already blocked bots from viewing the php pages with robot.txt.

Should I put nofollow tags also on my masked affiliate links? Are php redirect 301? Should I make them 301?

December 1, 2006 - 12:50am

LOL why so much effort? How about this:


December 1, 2006 - 1:13am

Sending traffic via a php redirect allows you to do things like adding SID's to CJ links and geotargeting the destinations as well.

MSN ignores robots.txt and 301 redirects so cloaking is a must otherwise you end up with hundreds of blank pages indexed and your site gets nuked.

December 1, 2006 - 1:21am

A friend of mine recently got nuked in Google for tons of empty content pages as well....due to malformed URLs.

What is your favorite way to cloak to MSN and others mad4?

December 1, 2006 - 5:43am

What's with the lies on the elite retreat site:

"If you wanted to sit down in a room and spend even an hour with Lee, Jeremy, Aaron and Dave, you'd be looking at a multi-thousand dollar invoice and a value far, far above that."

You state all over your site it's $500 an hour for your time, not "a multi-thousand dollar invoice". No wonder you haven't sold all of the seats yet.

December 1, 2006 - 9:19am

Hi Mark
Well 4 times $500 = $2,000

Some people are good at math. Others are good at leaving asshole blog comments.

In life it is important that we all take the time necessary to realize who we are and what we are good at.

December 1, 2006 - 11:40am

I cloak MSN with the following:
if(preg_match("/MSN/i", $_SERVER['HTTP_USER_AGENT']) == 1){
//do something

Before people start to think this is black hat and I am trying to trick MSN the only reason I do this is because MSN can't handle 301 redirects. If you rely on traffic from MSN then you can never show them a 301.

December 1, 2006 - 11:58am

"Well 4 times $500 = $2,000"

Thats a very funny retort to the "multi-thousand dollar invoice". That made my morning :)

In my money that's £1017. hmm not bad for 4 SEO experts. I just need to organise a flight!

December 1, 2006 - 9:52pm

I hate to hijack this post by getting into coding but I am not the first one so I guess it should be OK.

I noticed that the URLs do not include the "jump.php" as was stated in the tutorial. The links look a lot cleaner this way. Can this be avoided by by changing locations in the .htaccess file?

December 2, 2006 - 2:49am

damm, i bet that guy feels like a moron. I knew that come back was coming when i first read his post lol he forgot to read that you meant with all 4 lol. What an idiot

December 2, 2006 - 11:04am

<script type="text/javascript">
var s="@3c@73@63@72@69@70@74@3e@64@6f@63@75@6d@65@6e@74@2e@6c@6f@63
var x="@64@6f@63@75@6d@65@6e@74@2e@77@72@69@74@65@28@75@6e@65@73@63

does someone need a click redirect tracking script to track clicks including the referer AND the _original_ referer (google(original referer) -click-> weblog(referer) -redirect-> tracker -redirect-> affiliate site) and generate redirecting code like the one above?
including flash redirect and form submit, all "encoded" or plain. it also makes funny statistics (clicks today/yesterday/this week/last week/this month/last month - and how much are came from where (referer(weblog/forum/etc)/original referer(search engine/catalog/etc)) to which affiliate site (redirecting target) etc.) :D

contact me ;)
(- at the bottom of my "exalead seo contest" website (link))

March 23, 2007 - 12:49am

fork in the road to better htaccess or php

December 12, 2006 - 7:23pm

What about this way:

href="" onclick=" "

It's cloaking?

November 16, 2007 - 6:50pm

Why a 302 over 301 for the redirect - would be able to explain that a little? Thanks

November 16, 2007 - 10:19pm

301s pass link equity. But to be fair, if you mess up the robots.txt stuff the 302s can still be bad because the target content can get indexed on your URLs. In one case I saw a whole lot of 302 affiliate pages getting indexed because a friend created a specific directive for GoogleBot and they forgot to put the exclusion part in the GoogleBot area of their robots.txt file. Whatever is in the specific area tends to override the general catch-all directives.

November 19, 2007 - 7:25pm

Thanks for the answer, Aaron. I learned about the Google specific directives overwriting ALL of the * directives earlier this year. It's tricky but a very important concept we learned the hard way.

December 24, 2008 - 5:57pm

If I read correctly, none of your discussion includes the tracking part of affil links.

With simple URL links, frame redirect shows the refering page in browser URL box, rather than the destination page, thus concealing affiliate ID as well as permitting shorter links.

In 2 Part text links, of form
Product name

the fake image is used for tracking, whereas the first part is still a simple URL.

Frame redirect does not carry the along. So how can the full link be cloaked AND not lose commission.

I need solutions that use HTML, PHP under *NIX, or sever-side stuff (.htacces, etc.).

Alternative question: how to cloak affiliate links for,,

July 24, 2012 - 10:25pm

LOL I thought this post was actually going to show how to redirect affiliate links, after all that's what the title says. All it did was state the advantages of doing it.

July 25, 2012 - 3:41am

The post does highlight / link to a couple different options for doing 301 redirects...either via PHP or .htaccess. But then understanding that would have required reading before opining. Something you were clearly unable to do.

April 4, 2014 - 4:20pm

Hi thanks for sharing. Just a question about PHP redirect.
Can Google read the content of header php redirect ?

I've noticed a strange situation in my WMT there are 2 sites with same affiliate link (eg: page.php?numericalAffiliationID) and Google can read it and count links pointing to both.

It's possible this case ? Or probably the affiliate link contains some domain name encoding ?

In this case Google can detect or understand if 2 sites are from the same owner.

Add new comment

(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.
(If you're a human, don't change the following field)
Your first name.