HTTP redirects explained: 301, 302, 303, 307 and 308
Compare HTTP redirect statuses and consider method preservation, caching and migration behavior before choosing a redirect.
An HTTP redirect such as 301, 302, 303, 307 or 308 uses a response status and a Location header giving the target URL. Not every 3xx response sends the browser to a different URL: 304 concerns cache revalidation. Browsers load the new URL at once; apart from one extra round trip, users rarely notice. This article summarises MDN's "Redirections in HTTP" page, read in full on 15 November 2026.
Permanent versus temporary
| Code | Kind | Method handling (per MDN) | Typical use |
|---|---|---|---|
| 301 Moved Permanently | permanent | GET unchanged; other methods may become GET | site reorganisation |
| 308 Permanent Redirect | permanent | method and body unchanged | reorganisation with non-GET operations |
| 302 Found | temporary | GET unchanged; others may become GET | page temporarily unavailable |
| 303 See Other | temporary | GET stays GET; following POST, retrieve the result with GET | redirect after PUT or POST so a refresh does not repeat the action |
| 307 Temporary Redirect | temporary | method and body unchanged | like 302, better when non-GET operations exist |
MDN says permanent redirects imply the old URL should no longer be used, and crawlers and RSS readers update it. Crawlers do not memorise a temporary target. 308 and 307 were created because some clients changed the method on 301 and 302, against the specification's intent. Codes 300 and 304 are listed as special: 304 means a cached copy is still fresh.
Other ways to redirect
- HTML
<meta http-equiv="Refresh">: works only for HTML. MDN advises a delay of 0; this alone does not establish accessibility compliance for a whole page. - JavaScript
window.location: only works for clients that run JavaScript, but can be conditional. - Precedence: HTTP redirects first, then JavaScript redirects that run before load, then meta refresh, then JavaScript redirects after load.
- MDN's advice: use HTTP redirects when possible; if HTTP and meta redirects drift apart you can get infinite loops.
Use cases from the page
- Domain aliasing, such as
example.comtowww.example.com, or a renamed company. - Forcing HTTPS.
- Keeping links alive after URL changes: MDN says old links bring users and help SEO. For internal links, fix the links instead of redirecting, because each redirect costs an extra request.
- Using 303 after unsafe requests (PUT, POST, DELETE) and for long-running requests with a progress page.
- MDN says redirects affect performance and should be kept to a minimum.
Apache example from the page
The mod_alias Redirect and RedirectMatch directives create 302 redirects by default. Redirect / https://www.example.com also redirects everything under the path. RedirectMatch takes a regular expression. Because the default is temporary, confirm the status you actually send.
Other servers and loops
Redirect permanentorRedirect 301makes Apache's redirect permanent.- nginx: a separate
serverblock withreturn 301 $scheme://www.example.com$request_uri;, orrewritewithredirectorpermanentfor particular paths. The$schemeexample preserves the incoming scheme; it is a hostname-alias example, not an HTTP-to-HTTPS upgrade recipe. IIS uses a redirect element in its configuration. - Redirect loops: if a server detects one it may answer
500; across several servers, browsers detect it and show an error. MDN says a 500 soon after a config change likely means a loop, and that loops break the user experience entirely.
For a site that changes URLs
- Map each old URL to its closest equivalent. Redirect only where an equivalent exists; the page does not say what to do when none exists.
- Choose 301 or 308 for a permanent move. For a temporary location choose 302 or method-preserving 307; use 303 when the intended next step is to retrieve a separate result after an operation.
- Update internal links to the new URLs.
- Avoid chains: fewer redirects, fewer round trips.
Limits
We make no claim about how long search engines take to process redirects, which this page does not state.
By Omnistu.