›The Shack ›SEO ›301 vs 302 Redirects

301 vs 302 Redirects: Which One Should You Use?

Back to All Posts

Both redirects send visitors to the same place. A 301 and a 302 look identical in the browser: the user asks for one URL and lands on another. The difference is what you're telling search engines and browsers about the old URL, and choosing wrong can leave the wrong page in Google's index for months.

Short answer: use a 301 when the move is permanent and you want the new URL to replace the old one in search results. Use a 302 when the original URL will come back and should stay indexed. The rest of this post covers the cases where that rule isn't obvious, and how to set up and check each type.

What Each Status Code Actually Means

There are four redirect codes you'll run into regularly, not two:

  • 301 Moved Permanently: the resource has a new permanent home. Browsers cache this, often for a long time.
  • 302 Found: the resource is temporarily somewhere else. Keep using the original URL in the future.
  • 307 Temporary Redirect: same meaning as 302, but the browser must repeat the request with the same method and body.
  • 308 Permanent Redirect: same meaning as 301, with the same method-preserving guarantee.

The method distinction matters more for APIs than for pages. Historically, browsers turned a POST into a GET when following a 301 or 302, so form data was silently dropped. If you redirect an endpoint that receives POST requests, use 307 or 308. For ordinary page moves, 301 and 302 are fine. The HTTP status code reference lists all of the 3xx codes if you need the less common ones.

How Google Treats 301 and 302

A popular myth says a 302 doesn't pass link equity. That isn't how Google describes it today. Google has said that all of its supported server-side redirects pass PageRank. What differs is canonicalization, meaning which URL Google picks to show in search results.

  • A 301 or 308 is a strong signal that the target should become the canonical URL. The old URL drops out of the index and the new one takes its place.
  • A 302 or 307 is a weak signal. Google usually keeps the original URL indexed, because you said the move was temporary.

So a "temporary" redirect left in place during a site migration can keep old URLs showing in results long after the new pages went live. Google may eventually treat a long-standing 302 as permanent, but you're leaving the decision to an algorithm instead of making it yourself.

When a 301 Is the Right Choice

  • Changing a page's URL or slug (see our guide to URL slugs for getting it right the first time)
  • Moving from HTTP to HTTPS, or settling on www or non-www
  • Migrating to a new domain
  • Merging two thin pages into one stronger page
  • Retiring a page that has a genuinely equivalent replacement

When a 302 Is the Right Choice

  • A product is out of stock for a few weeks and you're sending visitors to a category page
  • A short maintenance window or a seasonal landing page
  • A/B tests that send part of the traffic to a variant URL
  • Sending signed-out users to a login page
  • Routing visitors by country or language, when the original URL should stay the indexed entry point

If you can't decide, ask yourself one question: in six months, should the old URL still exist? If the answer is no, it's a 301.

Setting Up Each Redirect

Apache (.htaccess)

# Single page, permanent
Redirect 301 /old-page/ https://example.com/new-page/

# Single page, temporary
Redirect 302 /summer-sale/ https://example.com/sale/

# Pattern-based with mod_rewrite
RewriteEngine On
RewriteRule ^blog/(.*)$ https://example.com/articles/$1 [R=301,L]

If you'd rather not write these by hand, the .htaccess generator builds redirect, HTTPS, and security header rules from a form. Our .htaccess cheatsheet covers the directives in more depth. For bulk redirect rules, TopWebPositions has a dedicated .htaccess Redirect Generator that handles 301 and 302 rules without any regex.

Nginx

location = /old-page/ {
    return 301 https://example.com/new-page/;
}

location = /summer-sale/ {
    return 302 https://example.com/sale/;
}

PHP

header('Location: https://example.com/new-page/', true, 301);
exit;

Watch out for this one: calling header('Location: ...') without a status code sends a 302 by default. Plenty of "permanent" PHP redirects in the wild are really temporary because the third argument was left off.

Checking Which Redirect You Actually Have

Don't trust the config file. Check the response. From a terminal:

curl -sIL https://example.com/old-page/ | grep -iE "^(HTTP|location)"

The -I flag fetches headers only and -L follows each hop, so you'll see every status code and Location header in the chain. The cURL generator builds this kind of command if you need custom headers or auth.

For a browser-based check, the Redirect & Header Checker on TopWebPositions traces every hop and flags loops and HTTPS-to-HTTP downgrades.

Test 301s in a private window. Browsers cache permanent redirects aggressively. If you set up a 301 by mistake and then remove it, your own browser may keep following it for days. Test new redirects in a private window, or with curl, which doesn't cache.

Redirect Mistakes That Cost Rankings

Chains. Page A redirects to B, B redirects to C. Each hop adds latency, and Google stops following after several hops. Point A straight at C. TopWebPositions explains why redirect chains quietly hurt SEO and has a walkthrough on auditing your redirect chains.

Redirecting everything to the homepage. When you delete a batch of pages and 301 them all to the homepage, Google often treats them as soft 404s because the destination isn't a real replacement. Redirect to the closest equivalent page, or let the URL return a 404 or 410.

Leaving internal links on old URLs. A redirect is a safety net, not a reason to stop updating links. Update your navigation, sitemap, and in-content links to point at the final URL so neither visitors nor crawlers need the redirect.

Using 302 for a migration. This is the expensive one. If a domain move or URL restructure uses temporary redirects, the old URLs can hang around in the index. Switch them to 301 as soon as you notice.

For the full list of response codes and how to debug each one, see how to read and debug HTTP status codes.