LinkerBite › Guides
How URL Shorteners Actually Work
What really happens between clicking a short link and landing on a page: slugs, database lookups, 301 vs 302 vs 307 redirects, and why some short links stop working.
LinkerBite Team · 2026-08-20 · 7 min read
A short link looks like a small piece of magic. You paste a long, messy address into a box, and you get back something like linkerbite.com/aB3xQ9. Anyone who opens that tiny address ends up on the original page. But there is no compression involved and nothing clever is hidden inside the characters. A URL shortener is really a lookup table with a web server in front of it.
Understanding how that works is useful even if you never build one. It explains why some short links load instantly while others feel slow, why a link you changed still sends people to the old page, how search engines treat short links, and why a short link you shared five years ago might now lead nowhere.
The two halves of a shortener
Every URL shortener does two jobs:
- Creating links. It takes a long URL, generates a short identifier (usually called a slug or key), and stores the pair in a database.
- Resolving links. When someone requests the short address, it finds the slug in the database and tells the browser where to go next.
The first job happens once per link. The second job can happen millions of times, so most of the engineering effort in a real shortener goes into making the lookup fast and reliable.
Slugs and keyspace
The slug is the part after the domain. Most shorteners build slugs from a set of URL-safe characters. A common choice is "base62": the digits 0 to 9, lowercase a to z and uppercase A to Z, which gives 62 possible characters per position.
The number of possible slugs is called the keyspace, and it grows very quickly with length:
- 4 characters: 62^4, about 14.8 million combinations
- 6 characters: 62^6, about 56.8 billion combinations
- 7 characters: 62^7, about 3.5 trillion combinations
That is why short links can stay short. Six or seven characters is enough for an enormous number of links.
There are two common ways to generate slugs:
- Counter-based. Each new link gets the next number from a counter, and that number is converted to base62. It is simple and never collides, but slugs are predictable: if your link is
abc12, someone can guess that abc13 exists and look at it. - Random. The service generates a random string and checks that it is not already taken. This makes links hard to guess, which matters if people shorten things like shared documents. The trade-off is a tiny chance of collision, which the service handles by simply generating another slug.
Some shorteners also let you choose a custom slug, such as /spring-menu. That is the same idea with a human picking the key instead of the computer.
A short link is not private. If a slug is short and guessable, anyone can stumble on it. Never rely on obscurity to protect a sensitive destination.
What happens when someone clicks a short link
Here is the full journey, step by step:
- The browser looks up the shortener's domain in DNS and connects to its server, usually over HTTPS.
- It sends a request such as
GET /aB3xQ9. - The server extracts the slug and looks it up, often checking a fast in-memory cache before falling back to the main database.
- If the slug exists, the server responds with an HTTP redirect status code and a
Location header containing the original URL. - The browser reads that header and makes a brand new request to the destination.
- The destination site loads as normal.
The whole detour typically adds one extra round trip to a server. On a good connection that is barely noticeable; on a slow mobile network, or when several shorteners are chained together, it adds up.
If the slug does not exist, the server returns an error page, usually with a 404 Not Found status.
You can watch this happen yourself. In a terminal, curl -I https://example-short-link sends a request without following the redirect, and the response headers show the status code and the Location it points to.
301 vs 302 vs 307: why the status code matters
The redirect status code is the most important technical decision a shortener makes, because it tells browsers and search engines how to treat the link.
301 Moved Permanently
A 301 says "this address has permanently moved to the new location." Browsers are allowed to cache this, and many do so aggressively. After the first visit, the browser may skip the shortener entirely and go straight to the destination.
That is fast, but it has a consequence: if the shortener ever changes where the link points, people who already visited may keep going to the old destination until their cache clears. Search engines treat a 301 as a strong signal that the destination is the canonical page.
302 Found
A 302 says "this resource is temporarily somewhere else." Browsers generally do not cache it unless the server explicitly says they can, so every click goes back through the shortener. That makes it suitable when a destination might change, or when the service wants each click to pass through its servers.
Search engines treat a 302 as temporary, so they may keep the short URL associated with the content for longer. In practice, search engines are good at working out what a redirect really means over time, but the code you choose is still the clearest hint you can give them.
307 Temporary Redirect and 308 Permanent Redirect
These are stricter versions of 302 and 301. The difference is about the HTTP method: with 307 and 308, the browser must repeat the request using the same method and body. If a form submitted a POST to the short URL, a 307 guarantees the destination also receives a POST. With 301 and 302, browsers historically switch a POST to a GET.
For ordinary links that people click, everything is a GET request, so 307 behaves much like 302 and 308 behaves much like 301. The distinction mostly matters for APIs and forms.
Which one should a shortener use?
- Use a permanent redirect (301 or 308) when the destination will never change and speed matters most.
- Use a temporary redirect (302 or 307) when destinations may be updated, or when every click should reach the shortener.
If you control your own redirects, avoid using a 301 while you are still testing. Browsers may remember it long after you fix a mistake.
Short links and SEO
A short link does not make a page rank better or worse on its own. Search engines follow the redirect and evaluate the destination. What matters is that the redirect is a clean, single hop to a working page.
Problems appear when links are chained (a short link that points to another short link that points to the real page), when the redirect leads to an error, or when the shortener adds an interstitial page that search engines cannot get past. Keep it to one hop where you can.
Link rot: why short links break
Link rot is the slow decay of links on the web: pages move, sites shut down, domains expire. Short links add their own layer of risk, because every short link depends on two things staying alive, not one.
Common reasons a short link stops working:
- The destination changed or disappeared. The short link still redirects, but to a page that now returns an error. The shortener is working fine; the target is not.
- The link expired. Some services delete links after a set period or after inactivity.
- The shortener shut down. If the service closes and nobody maintains its domain, every link it ever created stops resolving at once.
- The link was removed for abuse. Services disable links that point to phishing or malware. Occasionally legitimate links are caught too.
- A typo in the slug. Slugs are often case-sensitive, so
aB3xQ9 and ab3xq9 can be completely different links. - Copy-paste damage. Some apps add trailing punctuation or break the link across lines.
A checklist for using short links well
- Test every short link before you print or publish it.
- Use short links that do not expire for anything printed, such as posters, packaging or business cards.
- Point short links directly at the final page, not at another redirect.
- Keep a simple record of what each important short link points to, so you can spot broken destinations.
- Re-check links in long-lived content, such as documentation and old blog posts, every so often.
- Do not use short links to hide where a link goes. Recipients increasingly distrust links they cannot preview.
On LinkerBite, for example, you can create a short link without signing up, and those links do not expire, which removes one of the most common causes of breakage. The destination itself still needs to stay online, of course.
Wrapping up
A URL shortener is a mapping from a short key to a long address, plus a server that answers each request with a redirect. The slug's length sets how many links can exist, the redirect code decides how browsers cache the link and how search engines read it, and the link's lifespan depends on both the shortener and the destination staying alive. Once you know those moving parts, it is much easier to choose a shortener sensibly and to fix a link when it breaks.