O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


 
Buy the book!
Amazon Hacks
By Paul Bausch
August 2003
More Info

HACK
#4
Create Shorter URLs
Shortening a long Amazon URL is just a matter of knowing where to put the ASIN
[Discuss (12) | Link to this hack]

If you've ever tried to send a link to an Amazon product detail page to your friends via email, you know what a hassle those long Amazon URLs can be. Most email programs wrap the text at 72 characters and end up breaking the URL, often making it unusable. Next time, instead of copying and pasting the URL exactly as you see it, try cropping it a bit so the lines won't wrap. Here's what a URL copied directly from Amazon looks like:

http://www.amazon.com/exec/obidos/ASIN/0596004478/qid%3D1049157816/[RETURN]
sr%3D11-1/ref%3Dsr%5F11%5F1/104-2773718-4336742

For those of you keeping score at home, that's 114 characters! The core piece we're looking to dig out and preserve, the ASIN , is the only bit really needed to target the right product page. Everything after the 10-digit ASIN is garbage—session tracking and other bits and bobs used by Amazon—when we just want to link to the page. So we can instantly make a shorter link by removing the excess baggage:

http://www.amazon.com/exec/obidos/ASIN/0596004478/

That's much better. We're down to 50 characters, well within the non-wrap zone of most email clients. But if you really want to push the character-limit envelope, there's a little-known way (contributed by Cyrus Durgin at Amazon) to shorten the URL even further. You can replace exec/obidos simply with o, as in:

http://amazon.com/o/ASIN/0596004478

That brings us down to 35 characters. (OK, so maybe taking out the www. was cheating, but 39 is still impressive.) Now the URL is suitable for email, instant messages, or even writing out long-hand!


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.