The basic idea
A shortener stores the original URL in a database and assigns it a short code, like x7Qp9. The short URL is the shortener's own domain plus that code: https://bit.ly/x7Qp9.
When someone visits the short URL, the shortener looks up the code, finds the original URL, and sends an HTTP redirect back to the browser.
301 vs 302 redirects
A 301 is a permanent redirect — browsers and search engines remember it and may stop checking the short URL on later visits.
A 302 is a temporary redirect, which keeps the short URL in the loop on every click. Most shorteners use 301 or 302 strategically depending on whether they need to log every click.
Click tracking and analytics
Because every click passes through the shortener's servers, the service can log the time, referrer, country, and device of each click before sending users on their way.
That's why short links are popular in marketing — they double as a tracking layer without needing to add UTM parameters to every destination.
Trade-offs and risks
Short links hide the destination, which can be used for phishing. Always preview unknown short URLs with the Links Gorilla Redirect Checker before clicking in production.
If the shortener service shuts down, every short link breaks. For long-lived content, prefer canonical URLs on your own domain.