Skip to main content
SEO / Web
Published 7 min read

301 vs 302 vs 307 vs 308 Redirects: Which Status Code to Use

Two questions decide the code: is the move permanent, and must the request method be preserved?

Every redirect carries a three-digit status code, and the code tells browsers, crawlers and API clients two things: whether the move is permanent, and what to do with the request method. Choosing between 301, 302, 307 and 308 comes down to those two questions.

The short answer

CodeNamePermanent?Request method
301Moved PermanentlyYesMay change to GET for POST requests
302FoundNoMay change to GET for POST requests
303See OtherNoAlways becomes GET
307Temporary RedirectNoPreserved
308Permanent RedirectYesPreserved

Permanent versus temporary

A permanent redirect (301, 308) says the old URL is retired. Browsers may remember it and skip the old address in future, and search engines treat the destination as the page to index. A temporary redirect (302, 307) says the old URL remains the real one and the redirect is for now: maintenance, an A/B test, a regional switch. Caches generally do not store temporary redirects unless the response says they may.

Method preservation

When a client receives a redirect after a POST request, historic behaviour was to repeat the request as a GET. That is how 301 and 302 behave in practice in most browsers. 307 and 308 were defined to remove the ambiguity: the client must repeat the request with the same method and body. If you redirect an API endpoint that accepts POST or PUT and want clients to keep posting, use 307 for a temporary move or 308 for a permanent one.

Which should you use?

  • Page moved for good, ordinary website: 301.
  • Page moved for good and the method must stay the same, such as an API: 308.
  • Temporary move on a website: 302.
  • Temporary move that must keep the method: 307.
  • After a form submission, to send the user to a results page: 303.
  • http to https enforcement on a website: 301 is the common choice, followed by HSTS so browsers skip the redirect next time.

SEO considerations

Search engines read permanent redirects as a signal to consolidate to the new URL. A temporary redirect left in place for a long time may eventually be treated as permanent, but you should not rely on that. Use the code that states your intent. Whatever the code, avoid chains, and update internal links to point at the final address.

Examples

# Apache (mod_alias)
Redirect 301 /old-page https://example.com/new-page

# Apache (mod_rewrite) with a 308
RewriteRule ^api/v1/(.*)$ /api/v2/$1 [R=308,L]
# Nginx
return 301 https://example.com$request_uri;

Caching

301 and 308 responses can be cached by browsers and intermediaries, sometimes for a long time, so a mistaken permanent redirect can be hard to undo for visitors who have already followed it. Test with a temporary code first when you are unsure, and switch to a permanent one once you are certain. 302 and 307 are cached only if the response includes explicit freshness information.

Common mistakes

  • Using a 302 for a permanent move because it is the default in the tool you used. In Apache, R with no code sends 302.
  • Using 301 for an API endpoint where clients must keep the POST method.
  • Redirecting through several hops. See the redirect chains article.
  • Forgetting that a cached permanent redirect may persist in browsers.

Checking what a URL really returns

Read the response, not the rule. curl -I shows the status and Location header of the first response, and the Redirect Chain Analyzer on DevCraftKit explains the codes it finds and flags temporary redirects that look permanent.

Conclusion

Ask whether the move is permanent and whether the method must be preserved, and the code follows: 301 or 308 for permanent, 302 or 307 for temporary, with 303 for post-submission pages.

Frequently asked questions

Should I use 301 or 308?
Both mean permanent. 301 is the long-standing default and is fine for ordinary page moves. 308 guarantees that the request method and body are not changed, which matters for non-GET requests such as form posts or API calls.
Is 302 bad for SEO?
No, it is the right choice for a temporary move. Problems arise when a 302 is used for a permanent move, because it signals that the original URL is still the one to keep. Use a permanent code when the change is permanent.
What is a 307 Internal Redirect in my browser?
Some browsers show a synthetic 307 when they upgrade an http address to https because of a stored HSTS policy. The server never sent it; the browser did it before making a request.
What does 303 mean?
See Other. It tells the client to fetch a different URL with GET, and it is often used after a form submission to avoid a resubmission when the user refreshes.

The tool that pairs with this guide.

Did this help you untangle your redirects?

If these free developer tools save you time, consider buying me a byte. Your support helps keep DevCraftKit free and growing.

Buy me a byte 💾