This post is going to be a discussion about url shorteners, what the problems are, and how they could be useful, some potential business ideas. IT people will be familiar with these techniques, but these things are not obvious to everyone.


The basic idea is to take big url and make it shorter so it can more easily be shared. In some places its nicer to have short urls like http://stephenn.com/EEX23, for example on twitter where you have a limited space to enter a url. Another use case is where people are going to be typing the url rather than clicking on a link, maybe when a url is shown on a TV add. In other places its nice to have long descriptive urls like http://blog.stephenn.com/2014/03/javascript-apps-and-rendering-big-lists.html.

When someone uses a shortened url their browser go to the server which then redirects to the full url. The server has a mapping from the short url to the expanded one.

Generating Links
In the url http://stephenn.com/EEX23 the EEX23 is the link. You cannot use the same link for two different expanded urls. So how you generate those links becomes one of the main problems for the system. If you don't want them to look like a sequence, ie you don't want EEX24 to come after EEX23 you could randomly generate them, if that link is already used either try generating another or get the next available one in the sequence. If your a smaller host and don't have many links to shorten then this wont be an issue, however if your a big url shortener like goo.gl then these retries could get costly, you might want to precompute available links ready to be used, or you could do something clever based of the sequence. Iterate over the sequence but make sure its not sequential for one user, so they don't see the sequence.

Features
Some features that a url shortener could provide are.
* Customisable prefix's. If your links so they appear similar, you could have a prefix for a subject.
* Collect analytics. Although the target page can collect analytics and show the referrer.
* Changing or Deleting the link after its published. Maybe for corrections.

Business Use Cases
A customisable url shortener could be good for businesses like publishers. A news paper could provide short links within their content. Or any business that does email campaigns and links to content, might want short changeable urls.


Hosting
A provider could host many domains from the one url shortener server. The server could match on the host name coming in. The links only need to be unique across each host.