Skip to content

301 vs 302 vs 307 redirect: which one to use (with examples)

301 vs 302 vs 307 redirects: what each code tells Google, the lost PageRank myth, Apache and Nginx syntax, and a generator that writes your redirect rules for you.

301 vs 302 vs 307 redirect: which one to use (with examples)

A 301 redirect announces a permanent move, a 302 a temporary detour, and a 307 a temporary detour that preserves the HTTP method. For a redesign or a migration, the 301 is the right choice, no question. On the other hand, the idea that a 302 loses PageRank has been wrong for ten years, and it still circulates in articles published today.

301 vs 302 redirect: the difference comes down to one word

What each status code really announces

A redirect status code is a statement of intent addressed to browsers and crawlers. The 301 says: this URL has changed for good, forget the old one. The 302 says: get it from here for now, but the old URL is still the right one. That nuance has a direct consequence: Google indexes the destination URL on a 301, and keeps the source URL as the reference URL on a 302.

The browser draws a different conclusion: a 301 gets cached, sometimes for a long time. A 301 set by mistake can therefore keep redirecting your visitors after you have removed it from the server, which makes troubleshooting baffling. That is the real reason to be careful with it, far more than SEO.

301 vs 302 for SEO: the myth of lost PageRank

Many articles repeat that a 302 does not pass link value. That was true a very long time ago; it no longer is. Google confirmed in 2016 that all 3xx redirects pass PageRank, and John Mueller has said it again several times since, specifying that both codes are treated the same way when the redirect lasts.

What changes, then, is not the value passed but the choice of canonical URL. On a 302 kept in place for months, Google ends up treating it as permanent anyway, because the observed behaviour contradicts the declaration. In other words: the code expresses an intention, and your consistency over time decides the outcome.

Key takeaway

Choosing between a 301 and a 302 is not a trade-off between more or less SEO. It means answering a single question: will this old URL ever come back? If the answer is no, it is a 301.

307 and 308 redirects: the two codes nobody uses

The 307 preserves the HTTP method

Historically, browsers turned a POST request into a GET when following a 302, which the standard never intended. The 307 was created to remove the ambiguity: it is temporary, like the 302, but it guarantees that the method and the request body are kept. Its territory is therefore forms, APIs and checkout flows, not editorial pages.

One case where you will come across it without having written it: the browsers’ HSTS list, which forces the switch to HTTPS with an internal 307, before the request even leaves. It is not a redirect from your server, and it has no effect on your SEO.

The 308: permanent, and also method-preserving

The 308 is to the 301 what the 307 is to the 302: same meaning, with the method preserved. Google treats it like a 301. Useful on an API, unnecessary on a content site, where the 301 does the job and is understood by every tool.

301, 302 or 307: which redirect to use, case by case

Situation Code Why
Redesign, new URL structure 301 The change is permanent
Move to HTTPS, www or non-www 301 Only one URL should stay canonical
Merging two domains 301 Page to page, never to the home page
Product temporarily out of stock 302 The page will come back and must stay indexed
Two-week promotion 302 A return to the original is planned
Maintenance lasting a few hours 302 or 503 A 503 with Retry-After is more accurate
Form, API, checkout flow 307 The method and data are preserved

Redirect rules generator

Paste your URL pairs into the tool below, choose the type, and get the rules for Apache or Nginx. The generator escapes reserved characters and flags duplicates as well as obvious chains.

Redirect rules generator

One pair per line: old URL, then new URL, separated by a space, a comma or a tab.







301 redirect in .htaccess: the syntax that works

Apache, from the simple case to regular expressions

For a handful of URLs, the Redirect directive is enough and reads effortlessly. It expects a path as input and a full URL as output.

Redirect 301 /old-page/ https://example.com/new-page/
Redirect 301 /category/old-product/ https://example.com/shop/product/

For a repeating pattern, RedirectMatch saves you writing a thousand lines. The example below moves a whole section while keeping the end of the URL.

RedirectMatch 301 ^/blog/(.*)$ https://example.com/articles/$1

One point to watch: these directives are read in order, and the first one that matches wins. So put the specific rules before the generic ones, otherwise the latter swallow the former.

Nginx, and the permanent trap

On Nginx, the permanent keyword produces a 301 and redirect a 302. Many configurations carry a 302 set with no intention behind it, simply because that was the default word.

location = /old-page/ { return 301 https://example.com/new-page/; }
rewrite ^/blog/(.*)$ https://example.com/articles/$1 permanent;

Redirect chains and loops: the real poison

A redirect that leads to another redirect works, but each hop costs the visitor time and the crawler crawl budget. Google follows up to about ten hops before giving up, and that number is no guarantee. The working rule is simple: one hop, never more than two. On a site that has already migrated once, chains are almost always there, because the new rule was stacked on top of the old one instead of replacing it.

A loop, on the other hand, is immediately visible: the browser shows a « too many redirects » error. It often comes from a rule that redirects a URL to itself after normalisation, for example a trailing slash added and then removed by two competing rules. A site crawler finds them in a few minutes, and the URL Inspection tool in Search Console confirms what Google actually followed.

These checks are part of any serious technical SEO audit, and they are the first thing I check after a redesign.

Redirect mistakes to avoid

  • Redirecting every old URL to the home page. For Google this amounts to a deletion, and it is the leading cause of traffic loss after a migration.
  • Setting 301s during a test phase: they get cached in browsers and haunt you for a long time.
  • Redirecting to a page that itself redirects, instead of updating the final destination.
  • Forgetting images, files and feeds, which also receive links.
  • Leaving internal links pointing to old URLs and relying on redirects to catch them.
  • Removing the rules after three months. A year is the minimum, and on pages that receive external links you might as well keep them indefinitely.
Tom Lionne Independent SEO consultant since 2018. Let's talk about your site.
Read next