Get all new articles directly to your inbox!
Dealer Dan, pictured here with WWE Superstar Mick Foley, has been in internet marketing since 1996. He likes hugs, long walks on the beach, and making money while wearing his jammy jams. For more information, you can read all about Dealer Dan. » Posts » General & SEO Affiliate Guide » How To Redirect Affiliate Links

How To Redirect Affiliate Links

I’ve you’ve heard about redirecting affiliate links but are unsure as to the benefits of redirecting affiliate links, then please read my article: Why You Should Redirect Affiliate Links.

If however, you already know why you want to redirect affiliate links and are wanting to know how to redirect affiliate links then you’ve came to the right place.

How To Redirect Affiliate Links

There are a variety of options for you when it comes to redirecting affiliate links – the majority of them being extremely easy. There’s really no one “best option” so I’m just going to list here as many options as I can think of when it comes to redirecting affiliate links.

I’ll use Affiliate Bible as an example for all of these. Instead of seeing the affiliate link in every case, you would be seeing where affiliate-link.php redirects to that affiliate link.

ie: will redirect to:

(Quick note: Often affiliate links will resolve to the domain name. If you click the link above you will see that you ultimately end up at with no evidence of the affiliate link in the address bar. The affiliate links are still working – don’t worry. They’ve just now inserted a tracking cookie and made their site/landing page look more user-friendly).

Use .htaccess to Redirect Affiliate Links

This is a very popular one. You most likely have an .htaccess file in the root directoy of your domain. You can use this to redirect URLs from one URL to the other. So if you moved domains, you could redirect all your webpages from one domain to the other.

You can also use this to redirect affiliate links. Using Affiliate Bible as an example above, here’s how I would have my .htaccess file:

redirect 301 /go/hostgator.php
redirect 301 /go/focal-click.php
redirect 301 /go/godaddy.php
redirect 301 /go/slotland-affiliates.php

And that’s how you redirect affiliate links using .htaccess. As you can see you don’t need to put them in any particular order, so you don’t need to worry about putting them in alphabetical order or anything like that. If you ever need to update an affiliate link, you simply edit your .htaccess and replace the old affiliate link with the new one on the particular line.

Use Meta Refresh to Redirect Affiliate Links

This is a very simple one which you can use with .html files. You could also do it with .php files but there’s no point when there’s a much simpler PHP redirect(see next entry on this list). I’ll give you a step by step guide – let’s say we were going to do the hostgator example I mentioned:

1: Create the directory you want affiliate links to go in on your server. ie: /go/ (only have to do this once)
2: Open up notepad or equivalent, and paste the following text into a blank text file:

(I’ll explain that code in a second – click for big)

3: Save the file to your computer as hostgator.html for example.
4: Upload the file to your server in the required location ie: /go/.

That’s it. Now when you visit /go/hostgator.html it will automatically forward the visitor to the affiliate link. If the affiliate link changes, you simply update the URL in that particular file.

Now just to explain that code. The “META” tag is the important one. That tells the web browser that upon visiting that URL, it should immediately “refresh” the browser, and send it to the URL mentioned. Content=” basically means do it in 0 seconds, aka immediately.

The TITLE tag is not required, but I like to include it anyway. If the user happens to glance up at the title of the tab they’ll understand immediately that they’re being redirected. The BODY tag also isn’t really required either, but you might prefer for them to see a black background or similar when they click an affiliate link so I added that in.

If you wanted to do redirects in a folder style – ie: would forward to hostgator, then I’d recommend not doing this method. If you were to do that refresh via this method, you’d have to create a folder called “hostgator” in your root directory. You would then put the above code in a text file as normal, but save it as “index.html” or “index.php” and upload it to the /hostgator/ folder.

Using a PHP Redirect to Redirect Affiliate Links

While the Meta Refresh works in php files, I’d much rather use a simple redirect if using php files. All you would need to do is create a file called hostgator.php and then put this text in it:

And that will redirect hostgator.php to the affiliate link.

Use a Plugin to Redirect Affiliate Links

If you’re using a content management system, there are a variety of plugins you can use to redirect affiliate links. It depends on the CMS that you are using of course, and I’m not going to cover every CMS. Just google “______ Redirect Plugin” where the blank is whatever content management system you are using and you’ll find a variety of options.

Other Methods to Redirect Affiliate Links

There are a few other methods to redirect affiliate links, but the above 3 are basically the most commonly used, and the ones I would recommend.

Using a PHP Jump Script to Redirect Affiliate Links

This is one other really popular method that some websites use, and I felt I should mention it here. It’s involved creating just one php file where you can add a variable at the end to redirect the user.

Lets say I created for example(this doesn’t exist – please don’t attempt to index it Google!). When I link Hostgator, the link would be or if I linked Cake Poker, the link would be Poker.

To do that, I’d create the file visit.php in notepad, and have this text in it:

(Click for Full Size)

Line 2 basically says if the text variable isn’t within the php file, to send them to the homepage. You can play around with all of this too to better suit what you want. You may want to call the file go.php for example, and then change $v to $go.

And Remember:

Once you have set up your redirection links, be sure to use robots.txt to block Google from following or indexing the affiliate links.

Get all new articles directly to your inbox:

This article, as are all articles on, was written by Graeme aka "Dealer Dan". Graeme currently resides in Kingston, Ontario and has been running his own internet marketing business since 1996.

This article was written on January 21, 2012 however all articles are looked at on a monthly basis and updated to keep them relevant.

If you need to contact Graeme, please see his Contact Page. If you are an affiliate manager wanting promoted please see this page.
  • mrmarchuk

    Awesome Info, Thanks Graeme! I’ll have to set up that PHP Jump Script, as that seems pretty easy to modify 🙂

    Qiuck question though, are the PHP Jump Links automatically rel=NoFollow? I mean, obviously, i’d set the link pointing to the script as nofollow, but is there a way to make the links inside the jump script itself, NoFollow, as well as make the jump script nofollow/noindex?

  • DealerDan

    It would just be a case of telling robots.txt to nofollow visit.php or whatever the jump script is.


    @DealerDan:disqus Hi, I have a MyBB forum where users post links to various shopping websites. No I want that those links automatically convert into affiliate links. Please tell me how to do that!

  • DealerDan

    I had a quick look and I can’t see any mods for MyBB that would do that. Only thing I would suggest is switching to vBulletin. From a quick Google, it should be easy to do that.

  • monica

    MUITO BOM ACHO Q TODOS DEVERIAM TENTAR EU GOSTEI MUITO DA EXPLICAÇÃO Impressionante, obrigado ! Eu também vou ter de configurar o PHP Ir Script, pois parece muito fácil de modificar , como meu amigo ai de baixo …. desde já agradeço !!!!

  • DealerDan

    De nada!

  • Bryant Dodd

    if you use a php file to redirect an affiliate link do you just place the file in root directory of site if I use wordpress site? If so I did that and it dont redirect to my affiliate site. Just wondering if I need to do more than just upload it to root directory.

  • DealerDan

    You can place it wherever and it should work. What do you have in the file?

  • ezagent

    Dannyboy, I likes this damn page a lot. I mean I’s really really likes it because I a come here looking fer .htaccess infos and you is this silly dude selling the gambler and helping the affiliate newbie like me. Gods bless ya Dannyboy.

  • Deals Discount

    can someone please help me with this?

    I want to redirect*.*


    Basically I want to redirect all url’s pointing to with “Prefix Affiliate Code”

    How can i do that?

  • DealerDan

    Sometimes it can be a bit of trial and error. I’d try:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*)*.* [R=301,L]

  • Deals Discount

    I apologize if i have not given enough information. Basically it is not about only one affiliate domain ( It should also work for e.g. or etc. with different affiliate code.

    Code which should work for different affiliates with prefix and post-fix tracking codes.

    To explain better
    For I have Prefix code –*.*

    for I have Prefix code –

    for i have postfix code – ?affid=deals-21

    so i should be able to define it

  • DealerDan

    Yeah unfortunately I’m not too sure offhand. Would be something I’d have to test out and I just don’t have the time. If you figure it out please post it here would be helpful for others. Cheers.