My Personal URL Shortener
I wrote a really simple personal URL shortener a couple of years ago, and have been using it happily ever since. It's called shrtn ("shorten"), and is just a simple perl script that captures (or generates) a mapping between a URL and a code, records in a simple text db, and then generates a static html file that uses HTML meta-redirects to point your browser towards the URL.
It was originally based on posts from Dave Winer and Phil Windley, but was interesting enough that I felt the itch to implement my own.
I just run it on my laptop (shrtn <url> [<code>]
), and it has settings to
commit the mapping to git and push it out to a remote repo (for backup),
and to push the generated html files up to a webserver somewhere (for
serving the html).
Most people seem to like the analytics side of personal URL shorteners (seeing who clicks your links), but I don't really track that side of it at all (it would be easy enought to add Google Analytics to to your html files to do that, or just doing some analysis on the access logs). I mostly wanted it initially to post nice short links when microblogging, where post length is an issue.
Surprisingly though, the most interesting use case in practice is the ability to give custom mnemonic code codes to URLs I use reasonably often, or cite to other people a bit. If I find myself sharing a URL with more than a couple of people, it's easier just to create a shortened version and use that instead - it's simpler, easier to type, and easier to remember for next time.
So my shortener has sort of become a cross between a Level 1 URL cache and a poor man's bookmarking service. For instance:
- my blog: http://ofn.me/blog
- my microblog: http://ofn.me/mb
- some of my personas on the web: http://ofn.me/github, http://ofn.me/twitter, http://ofn.me/keybase
- various projects: http://ofn.me/shrtn, http://ofn.me/extract, http://ofn.me/spoor
- talks or blog posts I've done: http://ofn.me/pwp, http://ofn.me/ebill, http://ofn.me/pppm
- projects I'm interested in: http://ofn.me/pls, http://ofn.me/unglue, http://ofn.me/lmdb
- bookmarks for personal use: http://ofn.me/ci, http://ofn.me/time
If you don't have a personal url shortener you should give it a try - it's a surprisingly interesting addition to one's personal cloud. And all you need to try it out is a domain and some static webspace somewhere to host your html files.
Too easy.
[ Technical Note: html-based meta-redirects work just fine with browsers, including mobile and text-only ones. They don't work with most spiders and bots, however, which may a bug or a feature, depending on your usage. For a personal url shortener meta-redirects probably work just fine, and you gain all the performance and stability advantages of static html over dynamic content. For a corporate url shortener where you want bots to be able to follow your links, as well as people, you probably want to use http-level redirects instead. In which case you either go with a hosted option, or look at something like YOURLS for a slightly more heavyweight self-hosted option. ]