URL Shorteners (or URL Shortening services) have been of immense benefit to the online world. Posting long, unwieldy URLs was awkward especially when you want to post it on sites that limit character counts like some social media sites. Also, when all you want is an easy-to-remember URL. That's why these services still persist to this day.But there is one huge problem when it comes to them: Link Rot. So what is Link Rot? Let's assumme you are the owner of a teeny-tiny website somewhere in cyberspace. You post a link to one of your blog posts on a forum you frequent: http://my.website.com/path/to-blog-post. It works! People are clicking it to your website. But then suddenly...
URL Shortening is pretty simple. A user simply posts their long URL then a key is created that is mapped to the long URL. Let's take a pseudocode approach: User posts long URL. If it is a valid URL go to step 3. If not go to step 5. Create a unique key for the long URL. Save the long URL together with the unique key. If the URL is not valid return an error. As for the redirection: User clicks on our short URL (this creates a GET request). Get the "key" part of the URL. Lookup in your storage engine for the long URL that is mapped to the key. If the lookup is successful grab the long URL and return a re...