HTTP Fundamentals

HTTP Redirects: 301 vs 302 vs 307 vs 308

When to use each redirect status code and how they affect SEO, caching, and HTTP method preservation.

Why Redirects Matter

Choosing the wrong redirect type can break SEO rankings, cause caching issues, or change POST requests into GET requests unexpectedly.

The Four Redirect Codes

301 Moved Permanently

The resource has permanently moved. Search engines transfer link equity to the new URL. Browsers cache this redirect aggressively. Use for: domain changes, URL restructuring, removing trailing slashes.

302 Found

A temporary redirect. Search engines keep indexing the original URL. Caveat: Some older clients may incorrectly change POST to GET. Use for: A/B testing, temporary maintenance pages, geo-based routing.

307 Temporary Redirect

Like 302 but explicitly preserves the HTTP method. A POST request stays POST after redirect. Use for: temporary redirects where method preservation is critical (API endpoints).

308 Permanent Redirect

Like 301 but explicitly preserves the HTTP method. Use for: permanent URL changes for API endpoints that accept POST/PUT/DELETE.

SEO Impact

CodeSEO Equity TransferCached by BrowserMethod Preserved
301YesYesNo (may change to GET)
302NoNoNo (may change to GET)
307NoNoYes
308YesYesYes

Best Practice

For websites: use 301 for permanent moves, 302 for temporary ones. For APIs: prefer 307/308 to guarantee method preservation.

Protocoles associés

Termes du glossaire associés

Plus dans HTTP Fundamentals