Following the concerns over TinyURL and other third-party shortening sites, and lots of recent posts about creating our own discoverable short URLs and permanent redirects, I’ve created a plugin that will take care of all this for EE sites (especially those using quite short domain names).
The problem: Twitter users will be all too aware of the spread of confusing shortened URLs - the TinyURL, tr.im and bit.ly stuff. Over the last week, many have written about the problems of such URLs - bad usability, privacy loss, and the reliance on third-party URL-shortening mediators that could disappear at any time. Certainly, its unlikely that third-party short URLs will be around as long as most of the content they link to.
To divorce ourselves from those tools and provide our own short URLs (on any site) we need to:
Provide a meta link element with the rev=“canonical” and rel=“alternate shorter” attributes in the post’s head.
Provide a visible, clickable a link in the post’s body, again with rev=“canonical” and rel=“alternate shorter” as attributes.
Create a permanent redirect to the actual post, at its natural, elongated URL.
At present, only a few big sites (the likes of Flickr, Dopplr, PHP.net) are doing this, but as more sites embrace it, and more bloggers do the same, we’ll eventually have the critical mass, and maybe when we post those big links into Twitter it’ll automatically find the better short URLs we provide. Its worth the effort, however you look at it. There is already a tool that sniffs for your own short links, and even a short link sniffing bookmarklet.
To use, you’ll need to add two plugin tags to your main post (single entry) template, and create a new template group through which the permanent redirects will happen (using a third plugin tag). Its then just a case of amending two parameters, one being to specify the segment where the url_title is displayed in the URL.
Full details and further reading via my blog at (nice short URL) http://colly.com/s/774
Stats tracking the number of redirects from a short URL.
Big one: CP extension for Publish/Edit pages to allow use of a word to mask the entry_id when writing, so you could end up with domain.com/s/word.
Validation: currently no validation for missing parameters (won’t break though).
EDIT: Version 1.4 (attached) added 11th June 2009
Forces removal of www from short and destination URLs. Obviously you’ll need to ensure your site(s) can be found with and without “www”.
Also now supports any template path, including use of index.php or a renamed file (although its best to remove those to keep URLs as short as poss).
Also adds rel=“alternate shorter” to the links.
Finally, our man Glen has made the PHP more efficient.
v1.4: fixed a problem that we added in 1.3 that screwed up paths in some cases!
Colly (Simon Collison)