Blog

301 vs 302 redirects: which one to use

A 301 says a page has moved for good. A 302 says it's somewhere else for now and will come back. Visitors can't tell them apart, but search engines can, and the choice decides which URL appears in search.

The difference

Both send the visitor to another URL. What changes is what search engines do with the two URLs:

Google has said that 3xx redirects don't lose PageRank, so the choice isn't about "passing link juice". It's about telling search engines which URL you want them to show.

301, 302, 307 and 308

There are two permanent codes and three temporary ones. Google groups them like this:

CodeMeaningGoogle treats it asRequest method
301Moved PermanentlyPermanentMay change POST to GET
308Permanent RedirectPermanentKeeps the method
302FoundTemporaryMay change POST to GET
307Temporary RedirectTemporaryKeeps the method
303See OtherTemporaryAlways GET

For SEO, 301 and 308 are interchangeable, as are 302 and 307. The method difference matters for forms and APIs, not for pages people visit.

Two other kinds of redirect exist. A meta refresh with no delay is treated as permanent, and one with a delay as temporary. JavaScript redirects work only if Google renders the page, so use them only when you can't redirect on the server.

One thing to know about 307: browsers show an "internal" 307 when a site uses HSTS, which upgrades http:// to https:// inside the browser. That 307 never reaches the server or Googlebot, so a checker that requests the URL directly shows the real redirect the server sends.

When to use each

SituationUse
A page moved to a new URL301
Moving to a new domain301, page to page
HTTP to HTTPS, or adding/removing www301
Merging two pages into one301 from the one you remove
A product temporarily out of stock, sending people to a category302
A short promotion or seasonal page in front of a permanent one302
A/B tests that send part of traffic to a variant302

The simple rule: if you'll never point the old URL back at its old content, use a permanent redirect. If you will, use a temporary one.

How to check your redirects

Browsers follow redirects silently, so you can't see the code by visiting the page. Use a checker that records each hop and its status:

Paste one URL or thousands. Each result shows every hop's status code and destination, so you can spot:

In Search Console, redirecting URLs show up as Page with redirect in the Page indexing report. That's usually expected; the guide to Page with redirect explains when it isn't.

Setting them up

Apache (.htaccess):

Redirect 301 /old-page/ https://www.example.com/new-page/
Redirect 302 /sale/ https://www.example.com/summer-sale/

Nginx:

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

WordPress: a redirect plugin such as Redirection, or the redirect manager in Yoast SEO Premium or Rank Math, lets you choose the code per redirect. Check the default: some plugins use 302 unless you change it.

Shopify: URL redirects created in the admin are 301s. There's no setting for a temporary one.

In code: many frameworks default to 302. In PHP, header('Location: …') sends a 302 unless you pass 301; Express's res.redirect() also defaults to 302. Set the code explicitly.

Common mistakes

Questions

Is a 301 or 302 better for SEO?

Neither is better in general; they say different things. Use a 301 when a page has moved for good, so the new URL takes its place in search. Use a 302 when the original URL should stay in search because it's coming back.

What is the difference between 301, 302, 307 and 308?

301 and 308 are permanent; 302 and 307 are temporary. 307 and 308 keep the request method, so a form POST stays a POST, while 301 and 302 may turn it into a GET. Google treats 301 and 308 the same, and 302 and 307 the same.

Does a 302 redirect pass PageRank?

Google has said that 3xx redirects don't lose PageRank. The difference is which URL Google indexes: the target for a 301, usually the original for a 302.

How do I change a 302 to a 301?

Find where the redirect is set, whether that's the server config, a CMS plugin or application code, and change the status code there. Then check the URL again in the Redirect Checker to confirm it now returns 301.