How to Redirect a Link to Your Amazon Associates ID

by Michael on September 3, 2012 · 13 comments

If you have an Amazon Associates account, you might be wondering about the best way of managing your links. Sure, you could create a different link for every product, but that quickly gets unwieldy. Surely there’s a better way. Right?


Wouldn’t it be nice to feed the product ID into a standard link and let your web server craft the link for you?

What I’m talking about here, of course, is creating a redirect for your Amazon (or other) affiliate links. If you’re using WordPress to run your site, you could use a plugin to manage your affiliate redirects. But, as I’ve noted before, I don’t like using plugins for things that can be easily achieved with a bit of custom code.

What happens if the plugin’s creator loses interest and stops updating? It happens. And if it happens to you, you’ll be stuck with a huge cleanup project on your hands. Not worth it when you can roll your own solution in less time than it takes to find and install a plugin. Plus, the method outlined here works for just about any backend, not just WordPress.

The simplest solution (in my book) is to create a PHP redirect. To do this, create a .php file (i.e., just a text file containing a bit of PHP code) with the following:

<?php
$asin = htmlentities($_GET['asin']);
$link = "http://www.amazon.com/exec/obidos/ASIN/".$asin."/ref=nosim/jammersix-20";
header("Location:".$link);
?>

(sorry about the awkward line wraps)

Be sure to replace “jammersix-20” with your own affiliate ID — or don’t, if you’re feeling generous. ;-)

I named this file amazon.php and stashed it in /external at the root level of the domain. Thus, to use it, I simply link to:

http://www.jammersix.com/external/amazon.php?asin=xxxxxxxxxx

If you replace xxxxxxxxxx with the actual Amazon product ID number (ASIN = Amazon Standard Identification Number) the redirect will produce a well-formed Amazon link with your Associates ID that points to the product of interest.

The end product will look like this:

http://www.amazon.com/exec/obidos/ASIN/xxxxxxxxxx/ref=nosim/jammersix-20

For example, this link:

http://www.jammersix.com/external/amazon.php?asin=1430232498

results in an Amazon link that points to a handy book about PHP solutions for dynamic web design. The end product looks like this:

http://www.amazon.com/exec/obidos/ASIN/1430232498/ref=nosim/jammersix-20

Go ahead, click both versions. They work exactly as advertised.

Wondering how I found the ASIN? The easiest way is to just look at the page url after you’ve navigated to the product of interest. You’ll see it embedded in the Amazon url right after /dp/.

The beauty of this approach is that: (1) you’re not dependent on a third-party developer, and (2) if you ever change your affiliate ID in the future (or if Amazon changes the acceptable link structure) you only have to update it in one place.


{ 13 comments… read them below or add one }

Erica September 6, 2012 at 2:01 pm

Thanks for the tips. I use a redirection plugin which allows me to create a link using my own url. This way if they change the structure I just go in the back office and change the link that it directs to.

Reply

Corporate gift Ideas August 22, 2014 at 10:35 pm

Thanks for your marvelous posting! I truly enjoyed reading it, you are a
great author.I will make sure to bookmark your blog and will eventually come back later on. I want to encourage you to ultimately continue your
great job, have a nice afternoon!

Reply

Easy Way to hack subway surfers | August 23, 2014 at 7:48 am

Thank you a lot for sharing this with all people you
actually realize what you’re talking approximately!
Bookmarked. Please also consult with my website =). We will have
a link alternate arrangement between us

Reply

dui defense attorney sarasota September 1, 2014 at 4:16 am

My brother suggested I might like this web site.
He was entirely right. This put up actually made my day.
You cann’t consider just how a lot time I had spent for this info!
Thank you!

Reply

Moviestarplanet cheat mac September 5, 2014 at 8:54 am

Regardless of where you moviestarplanet hack have, the game to suit everyone
and anyone. There are so many people who are spread over a
vast range of players. As a matter of fact, this is so user-friendly that
players have their favorite games for free. There are numerous kinds of Navigational Points of Interest for the most out of the games popular analog control, the players need to do at home.

Reply

Frontline Commando 2 hakata ladata September 9, 2014 at 7:12 pm

Hi to ɑll, how is everʏthing, І tbink еvery one is getting more frօm
this site, annd your views are good designed for new people.

Reply

jetpack joyride cheat bot September 14, 2014 at 7:27 am

Making payments before playing a mobile application developers accessing an object-oriented
programming language and that of the Year” by shooting down everything that the user well. Mystery ManiaEA: It is fast and building high performance graphic based games, online jetpack joyride cheats game this day. The mobile games and also a feature of mobile apps downloaded daily, so games have the choice of a software development companies and friends.

Reply

www.konopnica.net September 18, 2014 at 11:44 pm

I don’t even know how I ended up here, but I thought this post was great.
I don’t know who you are but definitely you are going to a famous blogger if
you are not already ;) Cheers!

Reply

lose twitter followers September 20, 2014 at 5:39 am

Excellent goods from you, man. I have understand
your stuff previous to and you are just too fantastic.
I actually like what you have acquired here, really like what
you’re saying and the way in which you say it.

You make it entertaining and you still care for to keep it wise.
I can not wait to read far more from you. This is really a tremendous web site.

Reply

using led grow lights September 20, 2014 at 11:08 am

In the early 17th century, Phu Quoc was a desolate area where Vietnamese and Chinese immigrants earned their living
from the highly coveted sea cucumbers. We decided to pitch our tents at
the nearest campsite, so we could enjoy the views for another day.

There are many different styles and types
of equipment that can be purchased from your local grow shop or garden store.

Reply

Jacques September 21, 2014 at 5:40 am

I really like what you guys tend too bee up too.
This sortt of clever work and coverage! Keep up the very good works guys I’ve included you guys to my blogroll.

Reply

farmville 2 country escape hack apk download September 22, 2014 at 3:10 am

For developing mobile applications like free downloadable mobile software,
Mobile Games. Each game has been offering online games to the mobile user
farmville 2 country escape cheats can find the download.
You would be 220 million people all over the air. The keypad controls are essentially the
most popular platforms for mobile users.

Reply

Phil September 23, 2014 at 10:57 pm

The parent or guardian should visit Family Safety website and then remove
the monitored accounts. re in the market for a new family hatchback, you probably won. Would you like your family to spend more time together as a family.

Reply

Leave a Comment

Previous post:

Next post: