301 vs 302 redirects: which one to use

Short answer

Use a 301 when a page has moved for good, so the new URL takes its place in search. Use a 302 when the move is temporary and the original URL should stay in search. If you're not planning to change it back, use a 301.

The difference

Both send visitors to another URL, and visitors won't notice which you used. The difference is what you're telling search engines about which URL to keep.

301302
MeansMoved permanentlyFound, usually temporary
Signal to GoogleThe new URL should be canonicalKeep showing the original URL
What shows in searchThe new URLUsually the original URL

A redirect is one signal among several. Google says a temporary redirect can still end up with the target indexed if other signals point to it, and the old URL can keep appearing for a while after a permanent move.

All the redirect types

TypeHow Google treats itNote
301PermanentThe usual choice for moved pages
308PermanentKeeps the request method, such as POST
302TemporaryThe usual choice for short-term moves
303TemporaryOften used after a form submission
307TemporaryKeeps the request method
Meta refresh, 0 secondsPermanentUse only if you can't redirect on the server
Meta refresh, delayedTemporaryConfusing for visitors too
JavaScriptPermanentA last resort, as Google may not see it if rendering fails

From Google's redirects documentation. It prefers server-side redirects because they're the most reliably understood.

Which one to use

SituationUse
A page has a new URL301
Moving from HTTP to HTTPS, or to a new domain301
Merging two pages into one301 to the page that stays
Short maintenance or a brief campaign swap302
An A/B test that sends some visitors to another URL302
A page removed with no replacementNo redirect. Return 404 or 410

The common mistake is a 302 left in place for months after a permanent change. It's often a platform default or a quick fix that nobody revisited. If the old URL stays in search after a move, check this first.

Don't send removed pages to the homepage either. Google can treat that as a soft 404, and it's no help to the visitor. Redirect to a close replacement or let the page return a 404.

How to check a redirect

1Use curl 30 seconds

This shows the status and destination of every hop:

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

2Use the browser 1 minute

Open DevTools (F12), go to the Network tab, tick Preserve log and load the old URL. The first request shows its status code and Location header.

While you're there, count the hops. Google follows up to 10, but it advises redirecting straight to the final URL. If you can't, it suggests no more than 3 and always fewer than 5. Point your internal links at the final URL too. If the hops never end, see how to fix a redirect loop.

How to set one up

Keep permanent redirects for at least a year, which is Google's general advice for a site move. Longer is fine.

  • Apache: Redirect 301 /old-page /new-page
  • Nginx: location = /old-page { return 301 /new-page; }
  • Next.js: add it to redirects() in next.config.js. permanent: true sends a 308 and false sends a 307, not 301 and 302. Google treats them the same way.
  • Shopify: go to Content > Menus, then View URL Redirects. It only redirects URLs that are already broken, so a page that still loads won't redirect.
  • WordPress: use a redirect plugin or set it at server level. Check which status it sends, as the default may not be what you want.

Checking a page's links?

Find redirects from any page

Open SEOSnip on a page and run the link checker. It checks up to 100 of the page's links, plus its canonical and hreflang targets:

  • Internal links that redirect, with the final URL to link to instead
  • Canonical and hreflang targets that redirect
  • Meta refresh redirects, with their delay
  • A ticket with that evidence, and Check if fixed to run it again

It shows where a link ends up, not each hop, so use curl to count a chain.