Skip to content

302 vs 307

Found vs Temporary Redirect

302Found

Detour ahead! The page is temporarily hanging out somewhere else. We'll point you there!

HTTP Response
HTTP/1.1 302 Found
Location: /temporary-page

307Temporary Redirect

Quick detour! Go this way instead, but keep doing exactly what you were doing.

HTTP Response
HTTP/1.1 307 Temporary Redirect
Location: /alternative-endpoint
πŸ”€302Found
β†ͺ️307Temporary Redirect

Redirect Codes: Permanent vs Temporary

Permanent Redirects

301
Moved Permanently
πŸ“¦
Old-Style Permanent

Classic redirect

Resource has permanently moved. Browsers and search engines will update their bookmarks and indexes.

  1. POST /old-url
  2. Server responds with new location
    301 β†’ /new-url

⚠️ May change to GET

Key behavior:
  • Browser caches the redirect
  • SEO: Link juice transferred
  • ⚠️ May change POST to GET
308
Permanent Redirect
πŸ”’
Modern Permanent

Method-preserving

Like 301, but guarantees the HTTP method and body won't change during redirect.

  1. POST /old-url
  2. Server responds with new location
    308 β†’ /new-url

βœ“ Keeps POST method

Key behavior:
  • Browser caches the redirect
  • SEO: Link juice transferred
  • βœ“ Preserves HTTP method

Temporary Redirects

302
Found
πŸ”„
Old-Style Temporary

Classic temporary

Resource is temporarily at another location. Original URL should still be used in the future.

  1. POST /temp-moved
  2. Server responds with temp location
    302 β†’ /temp-url

⚠️ May change to GET

Key behavior:
  • No browser caching
  • SEO: Original URL preserved
  • ⚠️ May change POST to GET
307
Temporary Redirect
πŸ”ƒ
Modern Temporary

Method-preserving

Like 302, but guarantees the HTTP method and body won't change during redirect.

  1. POST /temp-moved
  2. Server responds with temp location
    307 β†’ /temp-url

βœ“ Keeps POST method

Key behavior:
  • No browser caching
  • SEO: Original URL preserved
  • βœ“ Preserves HTTP method

Quick Decision Guide

Use Permanent (301/308) when:
  • URL has changed forever
  • You want search engines to update their index
  • Domain migration or restructuring
  • Old URL should never be used again
Use Temporary (302/307) when:
  • Resource is temporarily unavailable
  • A/B testing or maintenance mode
  • You want to keep the original URL active
  • Redirect might change or be removed soon
Use Modern (307/308) when:
  • Redirecting POST/PUT/DELETE requests
  • Request body must be preserved
  • Working with REST APIs
  • Modern application with strict HTTP semantics
πŸ’‘

Key Insight

Permanent vs Temporary controls caching and SEO, while Old vs Modern controls HTTP method preservation. For APIs and POST requests, prefer 307/308. For simple page redirects, 301/302 are widely supported and sufficient.

Description

The URI of the requested resource has been changed temporarily.

When to Use
  • Legacy compatibility - prefer 307 for temporary redirects in new code
  • The redirect is temporary and the original URL should continue to be used
  • Warning: Historically changed POST to GET; behavior varies by client
Common Causes
  • Temporary maintenance redirect
  • A/B testing redirects
  • Temporary URL changes
Description

The server sends this response to direct the client to get the requested resource at another URI with the same method.

When to Use
  • Temporary redirect that must preserve the HTTP method (POST stays POST)
  • Redirecting form submissions or API calls temporarily
  • Preferred over 302 for modern applications
Common Causes
  • HTTPS redirect preserving POST data
  • Temporary URL change keeping method
  • Load balancing redirects

Decision Tree

Is this redirect temporary?

Yes

Must the HTTP method be preserved (e.g., POST stays POST)?

Yes

Use 307 Temporary Redirect

Status Code: 307

No

Use 302 Found

Status Code: 302

No

Use 301 or 308 (see 301-308 decision tree)

Status Code: 301