301 vs 302 redirect: which to use, and how Google treats 307 and 308

, Founder · Updated

Use a 301 redirect when a URL has moved permanently and a 302 when the move is temporary. Google treats a 301 as a strong signal to index the new URL and show it in search results; a 302 is a weak signal, so the old URL usually stays in results. 308 and 307 are the method-preserving versions of 301 and 302, and Google treats them the same way.

Key takeaways

  • 301 and 308 mean "moved permanently". Google indexes and shows the target.
  • 302 and 307 mean "temporarily elsewhere". Google keeps showing the source.
  • 308 and 307 stop clients from turning a POST into a GET. For normal pages the SEO effect matches 301 and 302.
  • Googlebot follows up to 10 hops, but every hop costs time. Redirect old URLs straight to the final page.

What the four redirect codes mean

RFC 9110 defines them:

CodeNameRFC 9110 meaningCan the method change?
301Moved Permanently"Assigned a new permanent URI and any future references to this resource ought to use one of the enclosed URIs"Yes, POST may become GET "for historical reasons"
302Found"Resides temporarily under a different URI", so clients keep using the originalYes, same note
307Temporary RedirectTemporary, and the user agent "MUST NOT change the request method"No
308Permanent RedirectPermanent, same wording as 301No

The method rule is why 307 and 308 exist. A form that POSTs to an old endpoint can silently become a GET after a 301 or 302, and the RFC points to 308 and 307 when that is undesired.

How Google treats each one

Google's documentation on HTTP status codes in Search and its redirects guide give the rules:

CodeSignal to Google's indexing pipelineWhat shows in search results
301Strong signal that the target should be processedThe redirect target
308Same as 301The redirect target
302Weak signalThe source page
307Same as 302The source page
303Treated like 302 by defaultThe source page

Google ignores the content served by the redirecting URL and processes only the final target. It recommends "a permanent server-side redirect whenever possible", and says to use permanent redirects "when you're sure that the redirect won't be reverted."

A redirect is one canonical signal among several. If a 301 points to page B but page B's canonical tag points somewhere else, or your sitemap still lists page A, you send mixed signals. Make the redirect target, its canonical tag and your sitemap agree.

When to use 302 or 307

Temporary redirects fit cases where the original URL is coming back:

  • A product page that sends visitors to a category page while the item is out of stock.
  • A short campaign or maintenance page.
  • Sending visitors to a localised page by country or language, where the original URL should stay indexed.

For a site migration, an https switch, a www or non-www decision, a slug change or merging two pages, use 301 or 308. Using 302 there leaves Google indexing URLs you meant to retire.

Avoid redirect chains

A chain is a redirect that leads to another redirect. The typical one is http://example.com → https://example.com → https://www.example.com. Google's crawlers follow up to 10 hops, so a two-hop chain will still be crawled. Each hop is another round trip before the page starts loading, though, and chains grow after every migration. Fix them by pointing every old URL straight at its final destination.

Our free redirect checker tests the http, https, www and non-www versions of a domain, plus index.html and trailing-slash variants of a page, and lists every hop. It flags versions that take more than one hop or use a temporary redirect.

How to set up a 301 redirect on each platform

nginx, from Google's guide:

location = /service {
  return 301 $scheme://example.com/about/service;
}

Use return 302 for a temporary redirect.

Apache (.htaccess or server config), also from Google's guide:

Redirect permanent "/old" "https://example.com/new"
Redirect temp "/two-old" "https://example.com/two-new"

Next.js, in next.config.js. Next.js docs say permanent: true sends 308 and permanent: false sends 307:

module.exports = {
  async redirects() {
    return [
      { source: "/old-blog/:slug", destination: "/blog/:slug", permanent: true },
    ];
  },
};

Vercel, in vercel.json. Vercel's docs also map permanent to 308 and 307, and accept statusCode when you need a literal 301:

{
  "redirects": [
    { "source": "/user", "destination": "/api/user", "statusCode": 301 }
  ]
}

Cloudflare Single Redirects can send 301, 302, 307 or 308, and default to 301, according to Cloudflare's settings reference.

How to check a redirect after you ship it

  1. Run curl -I https://example.com/old-url and confirm the status line shows 301 or 308 and the Location header holds the final URL.
  2. Run the redirect checker on the domain to catch chains between the http, https, www and non-www versions.
  3. In Search Console, inspect the old URL. Over time it should appear under "Page with redirect" in the Page indexing report, with the target indexed instead.
  4. Update internal links and the sitemap to the new URL, so Google stops hitting the redirect at all.

For what every other status code does in Google Search, see our HTTP status codes guide.

Sources

Questions

Is a 301 redirect better for SEO than a 302?
For a page that has moved for good, yes. Google treats a 301 as a strong signal that the target URL should be indexed and shows the target in search results. It treats a 302 as a weak signal and, per its redirects guide, keeps showing the source page. Use a 302 only when the move is temporary.
What is the difference between 301 and 308, or 302 and 307?
The method. RFC 9110 lets clients change a POST into a GET after a 301 or 302 for historical reasons. 308 and 307 forbid that, so a POST stays a POST. Google treats 308 the same as 301 and 307 the same as 302, so for pages served by GET the SEO effect is the same.
How many redirects in a row will Google follow?
Google's crawlers follow up to 10 redirect hops by default. That is a ceiling, not a target. Point each old URL straight at its final destination so a crawler and a visitor reach it in one hop.
How long should I keep a 301 redirect?
Google's redirects guide doesn't give a fixed period; it says to use permanent redirects when you are sure the redirect won't be reverted. In practice, keep them as long as old links in articles, emails or bookmarks still send visits; Search Console's Links report shows which external sites still link to the old URL.
Does Next.js send a 301 for permanent redirects?
No. Next.js and vercel.json send 308 for permanent redirects and 307 for temporary ones, to preserve the request method. Google treats 308 like 301, so this is fine for SEO. If you need a literal 301, set statusCode instead of permanent.

Related

See where you stand in Google and AI answers

Starter is $19 a month for one site, with a 14-day free trial and no card to start.