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...
Filesize: 1 KB