How URL Shortner Works?
You may know already what is URL. URL is a uniform resource locator. It is to used to locate files on internet. If you are viewing this blog on a browser then you must have click through a URL. But many time this URL become so big that it become difficult to remember it.
Let say you have a file on google drive and you want to send it to someone then you just simply create a sharing link from drive. But that link is so big that we cant able to remember it. Some time you may require to open that file every day so you are not going to type that long URL in your browser, it will take a lot of time.
Here URL shortner will help you. You may have seen vey small links like bit.ly/xyz or tiny.cc/abc and when you click on this links you will be on some other page which has a very long URL. What URL shortner do is it will take your long URL and give a shorter version of it and now instead of remembering that 50–100 character long URL you just have to remember 3–4 characters.
How It works under the hood
Whenever you go to any URL shortener like bitly or tiny.cc (and there are many more) they take your Long URL and then will generate a unique string for that URL. That unique string can be generated randomly or in some URL shortener you can also provide your own unique link.
Let see this with an example
You have a link of google drive : drive.google.com/verylongurlhere
You give this link to any URL shortner like bitly. So what bitly will do is it will create a random string and store it in a database with a mapping of your long link to this new link.
So when ever any one visits this short link bitly will check the database and will redirect him to the long URL. And if there is no long URL associated with that short link then it will give an Page not found error.
Some URL shortner like tiny.cc also provide a feature to set you custom short URL with the long URL. this helps even more to remember the short URL.
Try this (short URL for google) : http://tiny.cc/r7jauz