The Complete Guide to HTTP Redirects: 301, 302, 307, 308 and SEO Pitfalls

Why a Domain Migration Halved the Traffic

Platform defaults are usually 302 — a temporary borrow. Search engines keep the old address's equity where it was, the old domain stops receiving visits, and the rankings go with it.

One chain covers the choice: permanent with method preserved → 308, permanent → 301, temporary with method preserved → 307, temporary → 302, and POST that should become a GET → 303.

Four Status Codes: Semantics, Caching, Method

Status Name Semantics Cached? Method change
301 Moved Permanently permanent Yes (browser + SEO) POST→GET
302 Found temporary No legacy POST→GET
303 See Other view with GET No intentional to GET
307 Temporary Redirect temporary, keep method No keep method
308 Permanent Redirect permanent, keep method Yes keep method

Two details that cost people the most:

  • 301/308 are cached. Once a browser remembers the mapping, later visits to the old URL go straight to the new one, and a server-side change cannot reach clients that already cached it. That makes 301 right for a committed migration and wrong for a grey release; a rollback will not cover users who already stored the redirect.
  • 301/302 rewrite POST into GET. Early clients treated any redirect as "send it again as GET", so the request body disappeared. 307/308 exist precisely to remove that ambiguity: the client must repeat the original method and body.

Form submissions and payment callbacks hit the second point hardest. If the response is 301/302, the backend never receives the body and the order fields vanish. Either return 307 so the method is replayed, or return 303 to state clearly that the result page is fetched with GET — 303 is a deliberate conversion, not a loss.

The Location Header and Chains

The response header carries the target, and the client reads Location to pick the next hop:

HTTP/1.1 301 Moved Permanently
Location: https://new.example.com/path/to/page
  • A relative Location resolves against the current URL, so a relative path on a domain move lands back on the old host;
  • every extra hop costs another round trip, and a cross-host hop also pays a fresh DNS lookup and TLS handshake — far more than a same-host hop;
  • browsers and crawlers follow to the end, but give up with an error beyond roughly 20 hops;
  • point at the final URL in one step. Chaining A→B→C means any broken link in the chain kills the whole inbound link.

SEO: Where Link Equity Transfers

The difference between 301 and 302 is not technical behaviour; it is the signal sent to search engines. The first says the old address is retired and the index should move; the second says the original still works and is merely being viewed elsewhere for now.

Three boundaries — cross one and it becomes a penalty:

  • The content must be equivalent. Keeping a 301 after a rewrite that changed everything tells the engine the new page is a stand-in, and rankings drop with it.
  • Map one-to-one; never send the whole site to the homepage. A pile of old URLs 301-ing to the homepage reads as a cluster of dead links, and the homepage cannot serve those long-tail intents anyway.
  • Keep the 301 records and maintain them. The sitemap lists only new addresses, but deleting old URLs from the sitemap does not delete the external links pointing at them.

Cross-domain moves work the same way: a 301 is necessary, but equity only arrives if the new domain is crawled and indexed normally.

Redirect Loops: Causes and Diagnosis

A loop has exactly two shapes: A→B→A, or A pointing at itself. The cause sits in middleware, not business code:

  • a trailing-slash rule firing alongside another rule;
  • http↔https or www↔non-www canonicalisation running again on an already-canonical URL;
  • CDN origin rules and origin-server rules overriding each other.
# print headers per hop and see which jump returns to the original host
curl -sI -L --max-redirs 10 https://old.example.com

The fix is to canonicalise in exactly one place and decide the redirect after that decision. Two rule sets each adding their own hop will always trigger each other.

Three Scenarios, Pick Directly

Scenario Choice Reason
Old pages moved under archive/, old URLs retired 301 Permanent semantics; equity follows the new address
One-day grey release of a new design, possibly rolled back 302 or 307 Temporary semantics; the original stays valid
Redirect back to a list page after form submit 303 Result is fetched with GET, so refresh does not resubmit
A create endpoint that a gateway or client may retry 307/308 plus an idempotency key A redirect preserves the method only; duplicate creation still needs idempotency — see REST API design

Reproducible Results

A real 301 from this site (curl -I fetches headers only):

curl --noproxy '*' -sI http://127.0.0.1:3100/encoding-tools
HTTP/1.1 301 Moved Permanently
location: /encoding-tools.html
content-type: text/html

Read three things: the status line names 301 Moved Permanently; location is the target (curl follows it only with -L); and a 302 here would keep search engines indexing the old URL — the exact mechanism behind traffic lost to a mistyped status. Check each code's meaning in the HTTP status codes reference, and resolve targets with the URL parser.

Frequently Asked Questions

What's the real difference between 301 and 302, and why can 302 turn POST into GET?

301 is a permanent redirect, 302 is temporary—the difference is *semantics*, not just behavior. 301 is cached by browsers and search engines: later visits to the old URL go straight to the new one, and POST is rewritten to GET (migration is permanent, so duplicate-post risk surfaces under 301). 302 is not cached, but legacy implementations also rewrite POST→GET, so a form/payment POST can turn into a GET that loses parameters. For 'temporary but keep the method' see 307/308. Rule of thumb: permanent migration → 301 (passes SEO weight); temporary jump → 302/307; temporary keeping method → 307; permanent keeping method → 308; to prevent POST→GET use 307/308.

Why does my redirect lose POST parameters?

Because the response is 302 or 301, and clients (browsers, default curl, old proxies) treat a redirect as 're-fire as GET', dropping the POST body and headers. To keep the method you have exactly two options: ①the server returns 307 (temporary, keep method) or 308 (permanent, keep method); ②use 303 to deliberately say 'after redirect, view with GET'—303 is an intentional conversion, not 'lost params'. If you need the original data later, don't rely on the browser replaying the POST; persist it in a server session and hand the target page a GET with query params/fragment.

Why do redirects loop forever, and how do I prevent it?

A loop happens when Location points back to the same chain: A → B → A, or a rewrite rule redirects A back to A. Common triggers: ①middleware that force-adds/removes trailing slashes while the path contains an oddity re-rewritten again; ②scheme/case rules (http↔https, www↔non-www) re-firing on an already-normalized URL; ③CDN origin and origin-server rules overriding each other. Prevention: add a redirect hop guard (clients/browsers error out after ~20 hops), and on the server decide whether to redirect only after normalizing. To debug, capture the Location chain and use curl -L --max-redirs to see whose jump returns to the origin.

Should old revamped links be 301 or something else?

Use 301 whenever possible — if the old URL is fully retired and the new one is semantically equivalent. 301 transfers most of the old page's search-engine weight (link equity) to the new URL, so rankings follow the new address; 302 does not transfer weight—it just borrows the page temporarily, keeping rankings on the old address (fine for a short-lived experiment). But note three preconditions: ①content is truly equivalent (301-ing substantially different content reads as a downgrade); ②map one-to-one rather than redirecting everything to the homepage (301-to-home rows look like dead-link aggregation to SEO); ③keep the 301 table/sitemap maintained so old links don't become orphans.

← Back to Blog