Programming - - By Kevin Yank

Host Your Own Short URLs

nesting dollsIn the past week, the web development community received some news that many believed was inevitable, but came a lot sooner than expected: a major URL shortening service (in this case, tr.im) was shutting down. tr.im has since announced plans to stay in business, but even if they do, this serves as an important warning.

URL shorteners like tr.im have been all the rage since Twitter now famously encouraged us to express ourselves in 140 characters or less. These services take a relatively long URL (like the one you can see in the address bar if you’re reading this in a browser) and generate a teeny, tiny URL that redirects to it, which you can use to save characters when mentioning the link on Twitter.

URL shortening has become a competitive space, with contenders like TinyURL, is.gd, Metamark, ow.ly, Su.pr, thurly, tinyarro.ws, and TweaK. Each of these services offer a different combination of URL length, API support in third-party Twitter clients, URL visit tracking with statistics, and other novel features.

With its five-character host name and solid click stats, tr.im had fared well in the race. But when Twitter endorsed competitor Bit.ly by using it to auto-shorten URLs posted through twitter.com, tr.im faltered. Facing a long slog with no clear way to make money at the end of it, tr.im decided to shut down, and web developers went nuts.

The bright side was that all good URL shortening services send browsers onto the full URL using a permanent redirect (also known as a 301 redirect, after its HTTP response code). That means search engines like Google will follow the redirect to its target and only index that.

But, unlike Google, some people publish a URL without following the redirects. Many bloggers routinely copy shortened URLs from Twitter into blog posts verbatim, so when a URL shortening service like tr.im disappears, those links are broken.

In response to the outcry from developers, tr.im relented, scrapping its plans to, er, scrap the service. tr.im has now pledged to press on as a community-owned service, but without a plan to offset its ongoing hosting costs, tr.im’s public backflip may cost it the race.

In short (no pun intended!), URL shortening services significantly weaken the lattice of hyperlinks that hold the Web together. Developers who want reliable, permanent short links to their stuff need to find a better way to provide them.

The only way to free your short URLs from the risk of another individual breaking them is to generate your own and host them on your site. If you’ve done much server-side development, you can probably sketch out how to code this in your head fairly quickly.

If you aren’t a developer, you can check out some of the URL shortening plugins that have begun popping up. la petite url is a WordPress plugin that will generate short URLs for the posts on your blog automatically. Similar plugins are popping up for most popular blogging platforms and content management systems, but if you can’t find one for your particular publishing platform, Shaun Inman’s just-released Lessn is a solid standalone URL shortener that you can host yourself.

Of course, providing your own short URLs only solves the problem for links that you post yourself. Others may still link to you using fragile, short URLs created using one of the above services.

A proposed solution to this problem is short URL auto-discovery. The idea is you include in the head of your document a tag that advertises the short URL for this page:

<link rel="shorturl"
  href="http://example.com/1234"/>

The latest short URL plugins (including la petite url) will add this tag for you automatically.

In theory, Twitter clients and other software that needs to obtain short URLs will load your document, spot this tag (or the HTTP header equivalent), and use your published short URL rather than generating one using a third-party service.

In practice, although a handful of forward-looking sites are now publishing short URLs using this method, we have yet to see the first widely used application to support short URL auto-discovery. We can probably look forward to this happening soon, but the big win everyone is hoping for is that Twitter itself realizes the value of publisher-supported short URLs and begins using them instead of bit.ly when they are available.

Of course, Twitter could simply disregard URLs for the purpose of the 140-character limit and banish the evils of short URLs forever. Yeah, and monkeys might fly out of my butt.