Back in 2013 I wrote
shrtn, a super-simple
Personal URL Shortener
that I've been using happily ever since. As I wrote back then:
[It's] a simple perl script that captures (or generates) a mapping between a code and a URL, records it in a simple text db, and then generates a static html file that uses HTML meta-redirects to point your browser towards the URL.
This has a few features I really like:
It's a command line utility that is just a git clone away on any linux or mac box, so it's portable and private (no web interface that I have to authenticate to use).
urlmappings are automatically captured to git and can be pushed to multiple remote repos for backup e.g. github.com.
It can handle custom slugs (so ofn.me/shrtn, for instance), or it can generate random slugs for you.
That said, there are a few drawbacks with the HTML-META-redirect approach:
HTML META redirects work well with real browsers, but spiders and bots tend not to handle them. (This may be a feature, of course, depending on your point of view.) It would be nicer to use proper HTTP redirects instead, though.
Static webspace is cheap, but it's not free, and it's not trivially simple to setup and configure. There are plenty of providers that will give you a small VPS for $5/month that will do just fine for this, but that's still $60/year, and there's still the work of actually configuring a webserver properly and copying the html pages up, etc.
The web has moved on in the last 5 years, and there are now lots of interesting "cloud" options available that give us a lot of functionality for less, and are perhaps simpler to setup and maintain because they do more of the heavy-lifting for us. We can do better! :-)