301 vs 302 vs 307 vs 308: which redirect code to use
301 vs 302 vs 307 vs 308 explained: method rules from RFC 9110, where 303 fits, why Next.js sends 307 and 308, and the Chrome 307 that no crawler ever sees.
By Crawlito · 9 min read
In short
- 301 and 308 mean moved permanently and 302 and 307 mean moved temporarily; 307 and 308 also forbid the client from changing the request method, while 301 and 302 allow POST to become GET.
- Google treats 301 and 308 as a signal that the target should be canonical, and treats 302, 303 and 307 as temporary redirects that are not that signal.
- In Next.js, redirect() sends a 307 and permanentRedirect() or permanent: true in next.config.js sends a 308, so a moved page redirected with redirect() looks temporary to Google.
- A '307 Internal Redirect' in Chrome DevTools is created by the browser from HSTS or HTTPS Upgrades, carries a Non-Authoritative-Reason header, and never reaches your server or any crawler.
- Response headers such as Non-Authoritative-Reason, server, x-vercel-id and cf-ray, plus a request sent straight to the origin, tell you which layer issued a redirect.
On this page
- Which redirect code to use: the short version
- What RFC 9110 says about methods and caching
- Why Next.js sends 307 and 308
- The 307 Internal Redirect that only your browser sees
- How to tell which layer issued a redirect
- How to fix the wrong redirect code
- Frequently asked questions
- Check what your redirects really return
Use 301 or 308 when a URL has moved for good, and 302 or 307 when the move is temporary. The pairs differ in one way: 307 and 308 forbid the client from changing the request method, while 301 and 302 let a browser turn a POST into a GET. For crawlers fetching pages with GET, 301 and 308 behave the same, and so do 302 and 307. What matters is choosing permanent or temporary correctly.
The harder questions come from frameworks and tools that pick the code for you: why Next.js sends 307 when you asked for a redirect, where 303 fits, and why Chrome shows a 307 your server never sent. This post covers those. For how Google and AI crawlers treat every status code, including chains and loops, see status codes and redirects for AI crawlers.
Which redirect code to use: the short version
| Code | Name | Permanent? | Method on follow | Google's treatment | Use it for |
|---|---|---|---|---|---|
| 301 | Moved Permanently | Yes | May change POST to GET | Target treated as canonical | Moved pages, host and protocol changes |
| 308 | Permanent Redirect | Yes | Must stay the same | Same as 301 | Moved pages, moved API endpoints |
| 302 | Found | No | May change POST to GET | Followed, not a canonical signal | Short-term moves |
| 307 | Temporary Redirect | No | Must stay the same | Same as 302 | Short-term moves that receive POSTs |
| 303 | See Other | No | Becomes GET (or HEAD) | Same as 302 | After a form submission |
The Google column comes from Google's redirects and Google Search page. For a 302, 303 or 307 it says the indexing pipeline does not use the redirect as a signal that the target should be canonical, though the target might still be indexed if other canonicalization signals point to it. Google also says to use a permanent redirect when you are sure it won't be reverted.
At the time of writing, OpenAI, Anthropic and Perplexity do not publish how their crawlers treat individual redirect codes. Because a redirect lives in the HTTP response, any HTTP client can follow it, which is not true of a JavaScript redirect or meta refresh.
What RFC 9110 says about methods and caching
RFC 9110, section 15.4 defines the redirect codes. The four "this resource lives at another URI" codes are 301, 302, 307 and 308, and the RFC explains why there are two of each.
In HTTP/1.0, 301 and 302 were meant to keep the request method. Early browsers split on whether to resend a POST as a POST or as a GET, and the GET behaviour won. The specification now accepts that: for both 301 and 302 it says a user agent "MAY change the request method from POST to GET" for historical reasons. 307 and 308 were added later as the unambiguous versions. For 307 the RFC says the user agent "MUST NOT change the request method", and 308 is its permanent twin.
Two other differences are easy to miss:
- Caching. The RFC calls 301 and 308 responses "heuristically cacheable". A browser or proxy may store them without explicit cache headers, which is why a mistaken 301 can stick in browsers after you fix the server. 302 and 307 carry no such statement, so they are cached only when headers say so.
- Age. The RFC notes that 308 dates from June 2014 and "might not be recognized everywhere". Google lists 308 with 301 as a permanent redirect. A very old HTTP client may not recognize it, which is the main practical reason to choose 301 over 308 for GET traffic.
The RFC also says that a client following a redirect should drop or regenerate headers it added itself, such as Authorization and Cookie, and consider removing ones the calling code added where there are security implications. It says clients should detect redirect loops. It notes that an earlier version recommended a maximum of five redirects and that some clients may still enforce a fixed limit like that.
Where 303 fits
303 See Other is the code for "the answer to your request is over there, fetch it with GET". RFC 9110 says it is mainly used to send a browser somewhere else after a POST, so the result can be bookmarked and cached, and that the new URI "is not considered equivalent" to the original. That is the Post/Redirect/Get pattern:
POST /checkout HTTP/1.1
Host: www.example.com
HTTP/1.1 303 See Other
Location: /orders/1234A 303 is never the right code for a moved page. Google lists it with the temporary redirects, and it says nothing about the original URL having moved.
Why Next.js sends 307 and 308
Next.js uses the method-preserving pair everywhere. Its documentation explains the choice: many browsers changed a 302 POST into a GET, so it uses 307 and 308 to keep the method. What each API sends, according to the Next.js docs at the time of writing:
| Next.js API | Status sent |
|---|---|
redirect() | 307 |
permanentRedirect() | 308 |
redirects() in next.config.js with permanent: true | 308 |
redirects() with permanent: false | 307 |
redirects() with statusCode | The code you set |
redirect() or permanentRedirect() in a Server Action, form submitted without JavaScript | 303 |
The trap is redirect(). It is the first function most people find, and it sends a 307. If you use it to move an old blog URL to a new one, Google sees a temporary redirect and has no redirect signal to make the new URL canonical. For pages that have moved for good, use permanentRedirect() or, better, a rule in next.config.js. Config redirects are checked before the filesystem and before rendering starts:
// next.config.js
module.exports = {
async redirects() {
return [
{ source: "/blog/old-post", destination: "/blog/new-post", permanent: true },
{ source: "/promo", destination: "/spring-sale", permanent: false },
];
},
};If an older client really needs a 301, set statusCode: 301 instead of permanent: the docs say to use one or the other, not both. The same docs say Next.js adds a Refresh header to 308 config redirects for Internet Explorer 11 compatibility, which is a useful fingerprint later.
The streaming exception
The Next.js docs say that when redirect() or permanentRedirect() runs in a streaming context, it inserts a meta tag to redirect on the client instead. Once a streamed response has begun, its status line and headers have already gone out, so a 3xx is no longer possible. A crawler that reads the HTML without acting on the meta tag gets a page with a 200 status. The docs point to next.config.js or Proxy when you want to redirect before the render process, and those are the safest places for redirects that crawlers must see.
The 307 Internal Redirect that only your browser sees
Open Chrome DevTools, type http:// in front of your domain, and the Network panel may show something like this:
HTTP/1.1 307 Internal Redirect
Location: https://www.example.com/
Non-Authoritative-Reason: HSTSYour server did not send this. Chrome builds it itself: the Chromium function that creates these responses writes the Internal Redirect status text and the Non-Authoritative-Reason header (redirect_util.cc). The request never leaves the browser.
The rule behind it is HSTS. RFC 6797, section 8.3 says that when a browser is about to load an http URI for a known HSTS host, including when following a redirect, it "MUST replace the URI scheme with https" before making the request. A host becomes known when it has sent a Strict-Transport-Security header over HTTPS, or when it is on the browser's preload list. Some platforms send the header by default: Vercel's response headers page lists strict-transport-security: max-age=63072000, two years.
Chrome uses the same mechanism for its HTTPS Upgrades feature. The Blink intent to ship says Chrome upgrades eligible navigations to HTTPS "using a 307 internal redirect", visible in DevTools.
What this means for crawlers:
- No crawler receives this 307. It exists only in the browser's network layer, so it cannot be a temporary-redirect signal for Google or anyone else.
- It hides your real http behaviour. A browser that knows the HSTS policy never asks your server for the
httpURL, so you cannot see what a first-time visitor or a crawler gets. RFC 6797 section 7.2 says an HSTS host SHOULD answer plain-HTTP requests with a permanent redirect, such as a 301, to thehttpsURL. Check that the server actually does. - curl shows the truth. curl does not apply HSTS unless you turn it on with
--hstsand a cache file, so a plain request goes to your server:
curl -sI http://example.com/ | grep -iE '^HTTP|^location|^server'On a site behind Cloudflare, the output might look like this:
HTTP/1.1 301 Moved Permanently
Location: https://www.example.com/
Server: cloudflareHow to tell which layer issued a redirect
A redirect can come from the browser, a CDN, the web server or the application. They often disagree, and fixing the wrong one changes nothing. Read the headers on the 3xx response itself, not on the final page.
| Clue on the 3xx response | Likely source |
|---|---|
Non-Authoritative-Reason header, status text Internal Redirect | The browser (HSTS or HTTPS Upgrades); nothing to fix on the server |
cf-ray header and no headers your origin normally sends | Cloudflare, from a redirect rule or HTTPS setting |
server: Vercel with x-vercel-id | Vercel's edge; check vercel.json and framework config |
308 with a Refresh header on a Next.js site | A redirects() rule in next.config.js |
| Your application's cookies or custom headers on the 3xx | The application code |
server: nginx or server: Apache and no application headers | The web server config |
The server header is only a hint: Vercel's documentation notes that other proxies, such as Cloudflare, can override it. To be sure, compare the public response with a request sent straight to the origin, bypassing the CDN:
# Through the CDN
curl -sI https://www.example.com/old-page | grep -iE '^HTTP|^location|^server|^cf-ray|^x-vercel'
# Straight to the origin server at 203.0.113.10
curl -sI --resolve www.example.com:443:203.0.113.10 https://www.example.com/old-page \
| grep -iE '^HTTP|^location|^server'If the origin returns a 200 and the CDN returns a 301, the redirect lives at the edge, for example a Cloudflare Single Redirect, which offers 301, 302, 307 and 308 and defaults to 301. If both return the same redirect, it is in your server or application. If the origin redirects to http and the CDN back to https, you have found a loop.
How to fix the wrong redirect code
- List every redirect that matters. Old URLs from a migration, http to https, and the bare domain to
wwwor the reverse, as covered in choosing www or non-www. - Mark each as permanent or temporary. A renamed page, merged article or host change is permanent. A seasonal campaign, a maintenance detour or an A/B test is temporary.
- Check the code each one actually returns with
curl -sI, from outside the browser. - Change the code in the layer that issues it. In Next.js, swap
redirect()forpermanentRedirect()or apermanent: trueconfig rule. In a plugin or CMS that defaults to 302, change the setting to 301. - Keep one hop, and update internal links and sitemaps to the final URL so crawlers rarely need the redirect.
Keep permanent redirects in place long after the move; how long to keep 301 redirects covers how long. If Search Console still reports problems afterwards, fixing "Redirect error" walks through the common causes.
Frequently asked questions
Is a 308 redirect as good as a 301 for SEO?
Yes, for Google. Its redirects documentation treats 301 and 308 the same way, as a signal that the target should be canonical. The only difference is that 308 forbids changing the request method, which does not matter for crawlers fetching pages with GET.
Does a 307 redirect hurt SEO?
Not if the move is temporary. For a permanent move, Google does not treat a 307 as a signal that the target should be canonical, so the old URL may stay in results. Use 301 or 308 instead.
Why does Next.js redirect() return 307 instead of 302?
Next.js uses 307 so the request method is preserved, because many browsers turn a POST into a GET on a 302. Use permanentRedirect() or permanent: true in next.config.js when you need a permanent 308.
Why does Chrome show a 307 Internal Redirect on my site?
Chrome generated it because your host has an HSTS policy or because of Chrome's HTTPS Upgrades feature. It never reaches your server or any crawler, so check your real http-to-https redirect with curl instead.
When should I use a 303 redirect?
After a form submission or other POST, to send the browser to a result page fetched with GET. Do not use it for moved pages: it is a temporary redirect and does not say the original URL has moved.
Check what your redirects really return
The browser hides some redirects and invents others, so test from outside it. Run the free check on an old URL or your http:// homepage to see the status codes and final URL a crawler receives, or use an audit to check redirects across a migrated site with the evidence for each fix.
Filed under Access and robots.txt. Topics: redirects, http-status, google, nextjs