GUIDE

301 vs 302 redirectWhich redirect to use and why

Use a 301 (permanent) redirect when a URL has moved for good: migrations, HTTPS enforcement, canonicalisation. Use a 302 (temporary) redirect when the original URL should stay in use: maintenance pages, A/B tests, short-lived routing. 301s are cached by browsers and pass ranking signals to the new URL; 302s are not cached and keep the original URL indexed.

BlackhawkHub Editorial · Updated

The core decision

Ask one question: is this move permanent?

  • Yes301 Moved Permanently. The old URL should stop being used; signals move to the new one.
  • No302 Found. The old URL stays canonical; you are pointing elsewhere for now.

Everything else follows from that.

What each does

301302
MeaningMoved permanentlyTemporarily elsewhere
Browser cachingCached, often indefinitelyNot cached
Search enginesNew URL becomes canonical; signals consolidate thereOriginal URL stays indexed
ReversibilityHard (cached in browsers)Easy
Method preservedNot guaranteedNot guaranteed

When to use 301

  • HTTPS enforcement: redirect port 80 HTTP to 443 HTTPS. See HTTP vs HTTPS.
  • www ↔ non-www and trailing-slash canonicalisation.
  • Site migration or URL restructuring.
  • Merging duplicate pages into one.

Because browsers cache 301s hard, only use one when you are sure the change is permanent; reversing it is slow for anyone who cached it.

When to use 302

  • A maintenance page during a deployment.
  • A/B testing or temporary campaign variants.
  • Post-login bounce to the originally requested page.
  • Geographic or device routing where the generic URL should stay canonical.

307 and 308: preserving the method

Plain 301 and 302 permit a client to turn a POST into a GET when following the redirect, which browsers do. When the method and body must survive, for example redirecting an API POST, use:

  • 308 Permanent Redirect — permanent, method preserved.
  • 307 Temporary Redirect — temporary, method preserved.

Configuring

Apache:

apache
# Permanent
Redirect 301 /old/ /new/
# Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Temporary
Redirect 302 /promo/ /promo-2026/

nginx:

nginx
location = /old/ { return 301 /new/; }
server { listen 80; return 301 https://$host$request_uri; }
location = /promo/ { return 302 /promo-2026/; }

Testing

cmd
curl -IL https://example.com/old/

-I shows headers, -L follows the chain and prints each hop with its status. Watch for the correct code, a single hop (no chains), and the right final destination. See curl. During a migration, remember that browsers and resolvers may still hold old data; see DNS propagation.

Frequently asked questions

Does a 302 hurt SEO?

Not when used for genuinely temporary situations. The risk is using a 302 for a permanent move: it delays the consolidation of ranking signals to the new URL. For permanent changes use a 301. Google will eventually treat a long-lived 302 as permanent, but do not rely on that.

When should I use 307 or 308 instead?

When the HTTP method must be preserved. A plain 301 or 302 allows a POST to be re-sent as a GET; 308 (permanent) and 307 (temporary) guarantee the method and body survive the redirect. Use them for API endpoints and form submissions that must resubmit at the new location.

Sources