Short URLs

Tags: my blog.
By lucb1e on 2012-01-21 13:45:54 +0100

After thinking it trough and trough and trough, I've finally settled on a short URL scheme:
http://lucb1e.com/!shortname
Shortname can be a custom name I can set, or a blogpost ID.

Why this?
Well lucb1e.com/shortname would conflict with files on my server. I could include a long explaination what problems it would arise and how I could overcome them, but in the end it comes down to: It gets too complex. For something like this, I want to keep it as simple as possible. Preferably just one line of htaccess.

The most logical way after this was to use a subdirectory:
lucb1e.com/g/shortname
This was recognisable and easy to implement, but I dislike it. Other sites may use it all they like, but I want something more special and shorter. What is shorter than "g/"? Not much. What is easier to type than "g/"? Not much. But I did think of some things.

lucb1e.com/gshortname
The g would represent the goto, but unlike /g/ it wouldn't require a second slash. I did impement it (went easier than I had expected), but quickly found it to be confusing. There was no separator between the indication that it was a shortname and the shortname itself. I might have used lucb1e.com/Qshortname or /Xshortname, but that too was rather confusing.

Then I realised that lucb1e.com//shortname might be something. Insanely quick to type and as short as it gets (after just lucb1e.com/shortname). The only "but" was that users would find it confusing, two slashes? Was that a typo? Users wouldn't get it and they would mistake it.

Subdomains then, perhaps?
shortname.lucb1e.com
I really liked the idea, until I realised it would need to lookup the domain again and again. Not a big problem, but every milisecond counts in user experience, and I'm already hosting via a relatively slow home connection. According to site24x7 my website loads in 40-55ms on average, but that's from a Dutch server. A DNS lookup can easily double that loading time.

Next I tried a greater-than-sign:
lucb1e.com/>shortname
This seemed pretty good, an arrow-like sign to go to some place on the site. I tried to implement it, but Apache threw a fit again which I lost. It didn't want greater-than signs in a URL. At all. Even if they got forwarded, parsed otherwise, or anything else.

Lastly I looked up what characters were valid for an URL and chose one from that. They wouldn't have to be urlencoded so it would be 1 byte extra instead of 3 in the connection, and if someone entered a shortlink with a character that should be encoded but isn't, it wouldn't work.

So I settled on bangs. And they use an internal redirect, so only one HTTP request is needed to get the page. Try it yourself on this post:
lucb1e.com/!54

Update: Because relative URLs broke on this, I've changed it to external redirects. The redirect is a 301 though ("Moved Permanently"), so it gets cached. Use a /!shortname once, and the next time the browser will remember it was a redirect, thus doing it instantaneously.
lucb1e.com
Another post tagged 'my blog': About my website

Look for more posts tagged my blog.

Previous post - Next post