301 vs 308 and 302 vs 307: Which Redirect Keeps POST? Nginx, Express, Vercel and Astro Config
301 and 302 may turn a POST into a GET; 307 and 308 never do. Tested in Node, curl, Python and Chrome, with redirect config for Express, Next.js, Vercel, Astro and nginx.
On this page ⌄
The practical difference between the four main redirect codes is one question: if the client sent a POST, does the redirected request stay a POST? With 301 and 302 it may become a GET and lose the body. With 307 and 308 it must not. For a page that only gets GET requests (most redirects), 301 vs 308 is a distinction without a difference to a visitor, and the real choice is permanent vs temporary. This guide has the table, a test of five clients, and config for the stacks you are likely to use. To look up any other status code, use the HTTP Status Codes reference.
The four codes side by side
From RFC 9110 section 15.4 (from the RFC text, not a summary):
| Code | Meaning | Permanent? | POST becomes GET? | Cacheable by default? |
|---|---|---|---|---|
| 301 Moved Permanently | New permanent URI | Yes | May: "for historical reasons, a user agent MAY change the request method from POST to GET" | Yes (heuristically) |
| 302 Found | Temporarily elsewhere | No | May: same historical note | No, only with explicit cache headers |
| 303 See Other | Fetch the result with GET | No | Yes, by design: it points a POST at a GET-able result | No |
| 307 Temporary Redirect | Temporarily elsewhere | No | Must not: "MUST NOT change the request method" | No, only with explicit cache headers |
| 308 Permanent Redirect | New permanent URI | Yes | Must not (the 301 note points to 308 if the change is undesired) | Yes (heuristically) |
The RFC text also notes that 308 is younger (June 2014) than its siblings and "might not be recognized everywhere", with a pointer to RFC 7538 for deployment issues. "Cacheable by default" means a browser may reuse a 301 or 308 without asking again; for 302 and 307 it needs Cache-Control or Expires to do so. That is why a mistaken 301 is hard to undo.
What clients actually do with a POST
A test server answers POST /r301, /r302, and so on with that status and Location: /final, and logs the method and body of the request that reached /final. The client sent a=1 as a form body.
| Client | 301 | 302 | 303 | 307 | 308 |
|---|---|---|---|---|---|
Node 25.8 fetch | GET | GET | GET | POST + body | POST + body |
curl 8.18 -L | GET | GET | GET | POST + body | POST + body |
Python requests 2.34 | GET | GET | GET | POST + body | POST + body |
Chrome 156 fetch() | GET | GET | GET | POST + body | POST + body |
| Chrome 156 HTML form submit | GET | GET | GET | POST + body | POST + body |
All five agreed. In practice the "MAY" for 301 and 302 is a "does" in every client tested, so treat them as POST-destroying. This is why an API endpoint that moves needs 308 (permanent) or 307 (temporary), not 301 or 302: a client posting JSON would silently arrive as a body-less GET. Use 303 after a form POST to send the browser to a confirmation page (the Post/Redirect/Get pattern).
Copy-paste config
Every snippet below was either run (marked) or checked against the vendor's docs (marked). Not run: Apache.
Express 5.3 (run)
res.redirect('/new'); // 302 by default
res.redirect(301, '/new');
res.redirect(308, '/new'); // keeps POST
Tested against a local server with redirect: 'manual': GET /a -> 302 /new, GET /b -> 301 /new, POST /c -> 308 /new, GET /d -> 307 /new?x=1. The default is 302, not 301.
Next.js 16.4 (build output checked)
// next.config.js
module.exports = {
async redirects() {
return [
{ source: '/a', destination: '/', permanent: true }, // 308
{ source: '/b', destination: '/', permanent: false }, // 307
{ source: '/c', destination: '/', statusCode: 301 }, // exact code
];
},
};
After next build, .next/routes-manifest.json listed status codes 308, 307 and 301 for those three sources. No server was started to fetch them, so the manifest is the evidence. Note permanent: true is 308, not 301.
Vercel (vercel.json, from Vercel's docs)
{
"redirects": [
{ "source": "/me", "destination": "/profile.html", "permanent": true },
{ "source": "/user", "destination": "/api/user", "statusCode": 301 }
]
}
Vercel's docs say permanent defaults to true, and true means 308 while false means 307. Use statusCode for 301, 302 or 303. This config was not deployed; the live behaviour of this site, which is built on Vercel, was checked: a configured blog redirect returned HTTP/1.1 301 Moved Permanently with Location: /tools/aspect-ratio-calculator/.
Astro 5.18 (run)
// astro.config.mjs
export default {
redirects: {
'/old/': '/new/', // short form, no status given
'/gone/': { status: 301, destination: '/new/' },
'/temp/': { status: 302, destination: '/new/' },
},
};
Important for static sites: built with no adapter, Astro wrote HTML files, not HTTP redirects. dist/old/index.html contained <meta http-equiv="refresh" content="0;url=/"> plus <meta name="robots" content="noindex"> and a canonical link; the 302 entry used a refresh delay of 2 seconds (content="2;url=/"). A hosting adapter (Vercel, Netlify and so on) is what turns these into real status codes. If you need actual 301s on a static host, put them in the host's config instead.
nginx and Apache (not run)
location = /old { return 308 /new; } # permanent, keeps POST
location = /promo { return 307 https://example.com/; }
server { listen 80; server_name example.com; return 301 https://$host$request_uri; }
# .htaccess
Redirect 301 /old /new
RewriteEngine On
RewriteRule ^old/?$ /new [R=308,L]
These follow the standard directive syntax and were not executed, so run nginx -t or apachectl configtest before reloading. Support for return 308 needs a reasonably recent nginx; check yours.
SEO: what Google says
From Google Search Central (fetched 2026-11-02):
301and308mean the page permanently moved. Google follows them and uses them as a strong signal that the target should be canonical; with permanent redirects, the new target is shown in search results.302,303and307are temporary: Google follows them but treats them as a weak signal, and shows the source page in results.307is treated as302, and308as301.- Googlebot "generally follows 10 redirect hops"; Google's page says the codes differ semantically, so pick the one that fits.
No PageRank figures are claimed: Google's redirect page does not mention PageRank. The decision rule that follows is plain: use a permanent code (301 or 308) when the old URL is gone for good, a temporary code when you will bring it back, and avoid chains: each hop is a request, and A to B to C should be A to C.
A real chain-free 308: the trailing slash
To read a header block like the ones below as a table, use the HTTP Header Parser.
This site uses trailingSlash: 'always'. Requesting the slash-less URL gives a single permanent redirect to the canonical one, and the same for plain HTTP:
$ curl -sI https://xerobit.dev/tools/lorem-ipsum-generator
HTTP/1.1 308 Permanent Redirect
Location: /tools/lorem-ipsum-generator/
$ curl -sI http://xerobit.dev/
HTTP/1.0 308 Permanent Redirect
Location: https://xerobit.dev/
Both are 308 rather than 301. For a URL that only receives GETs the result for visitors and crawlers is the same (Google treats 308 as 301), and the host used the method-preserving code. Note one more thing from the earlier table: a browser may cache a 308 for as long as it likes, so confirm the destination before shipping a permanent redirect.
Choosing a code
- Page moved for good, GET only:
301or308. - Endpoint moved for good, clients may POST:
308. - Temporary move, any method:
307. (302if you know it is GET only.) - After a form POST, show a result page:
303. - Unsure? Use a temporary code first. A wrong permanent redirect is cached by browsers and takes time to undo.
Tested
2026-11-02, Windows 11: Node v25.8.0, curl 8.18.0, Python 3.11.15 with requests 2.34.2, Chrome 156.0.8078.48, Express 5.3.0, Astro 5.18.2, Next.js 16.4.4. Five-client POST table: one local server, all values from the request log. Express, Astro and Next.js outputs are as described above. Live headers come from curl -I against xerobit.dev on the same day. RFC 9110 text read from rfc-editor.org; Google statements from the Search Central pages; Vercel statements from vercel.com docs. nginx and Apache snippets were not run.
Keep reading
Related tools
HTTP Status Codes
Full HTTP status code reference with explanations and when to use each.
Hours Calculator
Add start, end and break times for each day to see daily hours, weekly totals and overtime instantly.
Character Counter
Count characters, words, sentences, lines and UTF-8 bytes with live SEO and social media limit tracking.
Keyboard Test
Press any key to see it light up and find dead, stuck or double-typing keys, with rollover checks for full size, TKL and 75% layouts.
Written by Mian Ali Khalid. More guides in Dev Productivity.