Back to blog

What is URL shortening and how does it work?

How a long address becomes a short link, how short codes are generated, and why shortening services use a 302 redirect instead of a 301.

Long URLs are awkward to share. An address with campaign parameters easily runs past a full line, and pasting it into print or a message often breaks across lines. URL shortening turns that long address into one short, stable link that sends people to the original when clicked.

How a short link is made

A shortener stores the original URL and issues a short code that points to it. In linkpado.com/xY3kP9q, the xY3kP9q part is the code. With just that code, the server can look up the original address and forward the visitor.

There are two common ways to generate codes.

  • Sequential: convert 1, 2, 3… into short characters. Simple to build, but the next link is predictable, and keeping the counter consistent across servers needs synchronization.
  • Random: pick a few characters at random from a fixed set. Hard to guess, and multiple servers can mint codes at once as long as collisions are avoided.

linkpado uses the random approach. It draws 7 characters from a set that excludes easily confused glyphs (0 vs O, 1 vs l) and retries with a different code on the rare chance one is already taken. Seven characters alone yield tens of billions of combinations, so collisions almost never happen.

What happens on a click

When you click a short link, the browser first hits the shortening service. The service looks up the original address by its code and sends the browser there with a redirect response. This usually finishes too quickly to notice.

One choice matters here. Redirects come in a permanent kind, 301, and a temporary kind, 302.

  • 301 lets the browser cache the result. From then on it skips the service and goes straight to the original — fast, but clicks stop being counted.
  • 302 routes through the service every time, so every visit can be measured.

That is why shorteners that offer click analytics use 302. linkpado responds to every short link with 302 so it can count exactly how often each link is clicked.

What makes a short link good

Short alone does not make a link good. Because a shared short link is hard to recall, it should be:

  1. Stable — once created, it should keep pointing to the same place.
  2. Safe — a link that hides any address invites spam and phishing. Trustworthy services set a policy on what can be shortened.
  3. Transparent — a click should reach the destination directly, with no interstitial ad or waiting screen.

linkpado meets that safety bar by only shortening URLs on approved domains, and keeps things transparent by forwarding straight through with no interstitial. If you want to make a link yourself, you can try it from the home page.