What a redirect is and why the code matters

When a request arrives, a server can answer with "the real address is over there" instead of content. That is an HTTP redirect, and its status code tells browsers and search engines whether the move is permanent or temporary. The visitor sees no difference; the destination page opens either way. The difference shows up in how long the browser remembers the redirect and which address search engines treat as the real one.

301: Moved Permanently

A 301 says "this address is gone; from now on always go there". Two practical consequences follow:

  • Browsers cache it. The next time the user types the old address, the browser goes straight to the new one without asking the server. That is fast, but if you ever want to undo the redirect, it can live in users' browsers for months.
  • Search engines record the target as the canonical page. Most ranking signals earned by the old URL are transferred to the new one, and the old URL drops out of the index over time.

When to use it: a domain change, moving from HTTP to HTTPS, choosing between the www and bare versions of a domain, permanently restructuring URLs, or pointing a deleted page to the closest related page.

302: Found (temporary)

A 302 says "go there for now, but this is still the real address". Browsers do not cache it by default; they ask the server every time. Search engines keep the original URL in their index.

When to use it: a maintenance page, an A/B test, sending traffic to a campaign landing page for a limited time, routing by language or device, or sending a logged-out user to the sign-in page. In short, whenever the destination may change later, 302 is the right choice.

307 and 308: the method-preserving siblings

With 301 and 302, some clients turn a POST into a GET when following the redirect, and the form data is lost. 307 (temporary) and 308 (permanent) require the client to keep the same method and body. If you redirect an endpoint that receives form submissions or API calls, use 307 instead of 302 and 308 instead of 301. For ordinary page redirects, 301 and 302 are fine.

Redirect chains: the silent cost

A chain is a redirect that lands on another redirect: http://example.com/old → https://example.com/old → https://www.example.com/old → https://www.example.com/new. Each hop is a separate network round trip. On a mobile connection, three hops easily add more than a second, during which the visitor stares at a blank screen.

Chains are rarely created on purpose; they accumulate. First the site moves to HTTPS, then the www convention is chosen, then a page is moved, and each step adds its own rule. They cause three problems:

  1. Speed: every hop adds latency, and if the first hop is HTTP, an unencrypted request goes out as well.
  2. Crawl budget: search engine bots stop following after a certain number of hops, and the destination never gets crawled.
  3. Loops: if A → B → A ever occurs, the browser shows a "too many redirects" error and the page does not open at all.

The rule: every old URL should reach its final destination in one hop. When you add a new redirect, update the targets of existing rules as well instead of chaining old onto new.

How to see a chain

Browsers hide the chain; the address bar shows only the final destination. Query a URL with the HTTP headers tool and look at the first response's status code and Location header. Query that location again; if you see another redirect, you have a chain. During a migration, checking the twenty most visited old URLs this way catches most of the problems.

Which code should short links use?

Short-link services almost always use 302 (or 307), and for good reason: a short link's destination must stay editable. Updating the target behind a printed QR code after a campaign ends is only possible because browsers do not cache the redirect. It also means every click reaches the server, so click counts and referrer analysis stay accurate; with a 301, the second click would never arrive and would never be counted. Use 301 for a domain move whose target will never change, and 302 wherever you need a dynamic destination and measurement.

Checklist

  • Is the move permanent? → 301 (308 for form or API endpoints)
  • Might the target change, or do you need measurement? → 302 (307 for form or API endpoints)
  • Does every old URL reach its destination in a single hop?
  • Are the HTTP-to-HTTPS and www rules combined into one rule?
  • Have you verified the old URLs with an external tool?

If you want editable destinations, click analytics and UTM tracking in one place, take a look at the h8x features.