A redirect tells the client that the resource is somewhere else, with the new address in the Location header. There are five common redirect codes, and they answer two questions differently:
- Is the move permanent or temporary?
- Will the client keep the request method (and body), or may it switch to
GET?
The quick table
| Code | Name | Permanent | Method on redirect |
|---|---|---|---|
| 301 | Moved Permanently | Yes | May change POST to GET |
| 302 | Found | No | May change POST to GET |
| 303 | See Other | No | Always GET |
| 307 | Temporary Redirect | No | Preserved |
| 308 | Permanent Redirect | Yes | Preserved |
For setup examples and SEO notes on the two most common codes, see the guides to 301 Moved Permanently and 302 Found.
Why 307 and 308 exist
The original specification said clients should not change the method on 301 and 302. Browsers did anyway: they turned a POST into a GET and dropped the body. The behavior became so widespread that RFC 9110 now allows it, and 307 and 308 were added for when the method must be preserved.
- 301 and 302: browsers keep GET as GET, but a POST usually becomes a GET.
- 307 and 308: the client repeats the same method with the same body.
For page URLs that are only ever fetched with GET, 301 and 308 behave the same in practice, as do 302 and 307.
Permanent vs temporary
Permanent (301, 308) means "update your links". Browsers cache permanent redirects, often without an expiry, and search engines transfer ranking signals to the new URL and eventually show it instead of the old one.
Temporary (302, 303, 307) means "go there for now, but keep using this URL". Browsers don't cache them by default, and search engines keep the original URL indexed.
Because browsers cache 301s aggressively, a mistaken permanent redirect is hard to undo. Test with a temporary redirect first, then switch.
Which one to use
| Situation | Code |
|---|---|
| Moving a page or domain for good | 301 or 308 |
HTTP to HTTPS, or www to bare domain |
301 or 308 |
| Renamed API endpoint that accepts POST/PUT | 308 |
| Temporarily sending users elsewhere (maintenance, A/B test) | 302 or 307 |
| After a form POST, show a result page | 303 |
| Login redirect to the page the user wanted | 302 or 303 |
Language or region redirect from / |
302 or 307 |
The POST/redirect/GET pattern
After a successful form submission, respond with 303 to a result page. The browser loads it with GET, so refreshing the page doesn't resubmit the form:
HTTP/1.1 303 See Other
Location: /orders/1042
Examples
nginx
server {
listen 80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}
location = /old-page { return 308 /new-page; }
Apache (.htaccess)
Redirect 301 /old-page /new-page
RedirectMatch 302 ^/sale$ /summer-sale
Express
app.get("/old-page", (req, res) => res.redirect(301, "/new-page"));
app.post("/submit", (req, res) => { /* save */ res.redirect(303, "/thanks"); });
Next.js
// next.config.js
module.exports = {
async redirects() {
return [{ source: "/blog/:slug", destination: "/articles/:slug", permanent: true }];
},
};
Next.js uses 308 for permanent: true and 307 for permanent: false, so form posts keep their method.
How fetch and curl handle redirects
fetchfollows redirects by default (redirect: "follow"). Useredirect: "manual"to stop, though in browsers you then get an opaque response without theLocationheader.curldoesn't follow redirects unless you pass-L. Add-Ito see just the status andLocation:
curl -sIL http://example.com | grep -iE '^(HTTP|location)'
Copying a failing request from DevTools and replaying it like this is often the quickest way to see a redirect loop; see Copy as cURL.
SEO checklist for site moves
- Map every old URL to its closest new equivalent; avoid redirecting everything to the homepage.
- Use permanent redirects, one hop each, with no chains.
- Update internal links, canonical tags, hreflang and the sitemap to the new URLs.
- Keep redirects in place for at least a year; longer is better.
- Watch crawl errors in Google Search Console after the move.
Shared links keep showing the old preview until platforms re-scrape the page; the Open Graph guide covers refreshing them.