Bitly maintains a table of short id and long url. When you enter bit.ly/2GWhfP, the request is sent to bitly server. The server parse the url to get the short id. It looks for the id in db to get real url. Server then respond back with a 301 redirect status and redirect url. Browser redirects to that url.
Normal response to browser from server will be 200. It tells browser to render the html. 300 tells browser to redirect. 404 - not found. 500 internal server error. Research on http status codes
Read my blog post - Create your own private url shortener for free coffeencoding.com/how-to-create-your-own-private-…