A short link such as lnkiy.com/abc12 does not contain your long URL. It is a key that points to a record stored in a database. Understanding that one idea explains almost everything a URL shortener does.
Step 1: creating the short link
When you paste a long URL, the service validates it, stores it, and generates a short, unique identifier, often called a slug. Slugs are usually 5 to 8 characters drawn from letters and digits. With 62 possible characters, even six characters give more than 56 billion combinations, so collisions are easy to avoid. With a custom URL you choose the slug yourself, as long as nobody else has taken it.
Step 2: the click and the redirect
When someone opens the short link, their browser asks the shortener's server for that slug. The server looks it up and replies with an HTTP redirect that contains the destination in a Location header. The browser follows it automatically, and the whole round trip normally takes a few milliseconds.
301, 302 and 307: which redirect is used?
- 301 (permanent) tells browsers and search engines the destination will never change. Browsers may cache it, so later clicks might skip the shortener, and some clicks will not be counted.
- 302 and 307 (temporary) tell the browser to ask again every time. This is what most analytics-driven shorteners prefer, because every click reaches the server and can be recorded.
Step 3: how clicks are measured
Because every visit passes through the shortener first, it can record the time, the approximate location derived from the IP address, the device and browser from the user-agent header, and the referrer. This is how a dashboard can show clicks by country, device and traffic source without any code on the destination page. See how this works in practice on our link analytics page.
What shorteners cannot do
A shortener cannot make a slow destination faster, and it cannot guarantee that the destination is safe. That is why previewing a link before you click matters; our guide to spotting malicious short links explains how. You can try the mechanics yourself with the free short URL tool.
Ready to try it?
Make a short link in seconds. It is free and no sign-up is needed.
Create a short link