~ 2 min read

Create Your Own TinyURL Service for WordPress

I don’t particularly like using URL shortening services. I think I first noticed them getting used rather prolificly in the Guardians technology section to include lots of random links to bizarre web content. TinyURL’s own web site wouldn’t particularly inspire me to go ahead and make use of it either. But, because of my own use of services such as twitter, I’m forced to shrink down links to get within those 144 characters.

Herein lies a problem – If said URL shortening service disappears, all my links are broken to all that interesting content I worked so hard to find. Not good.

In order to our bit to help, a number of developers and even services have taken action in order to make sure they provide alternatives for the links over which they’re responsible.

I’ve installed a plugin here which uses the recently puchased domain “woot10.eu” to provide alternative links using the code <link rev="canonical" href="shorter link" />. My full ianwootten.co.uk domain does not lend itself well to be able to provide a shorter URL on the same domain unforunately.

There is a whole huge discussion on the approriateness of using this technique (mainly) due to the rev attribute not being included in the HTML5 spec. See the comments in Chris Shifletts post for more on this.

Anyway, Duncans plugin takes the id of any wordpress post and coverts it to base 36 (instead of 10) and offers up the alternative in the header of each post. I believe the conversion could go all the way up to 62, if php’s base conversion actually supported the use of different cases in conversion.

In my own case, I’ve had to forward the links from woot10.eu across to www.ianwootten.co.uk using a .htaccess file so that the plugin is actually able to pick them up.

Now when you visit:

http://woot10.eu/p8p you’ll be forwarded on to the longer URL such as https://www.ianwootten.co.uk/2009/05/15/my-vicious-circle-of-posting-quality-content.

This isn’t particularly useful if you want to find the alternative for URL, as you’ll have to hunt through the source of a post. For that I’d suggest Simons bookmarklet which looks for an alternative link, or creates one if it doesn’t exist using tinyurl. As an aside, there looks to be an interesting talk on the canonical attribute and link element by Matt Cutts of google here.