Methods and request semantics
301, 302, 303, 307 and 308
Redirects can change the method.
Understand the concept
Location supplies another address. 301 is permanent and 302 temporary; historical client behaviour may change POST to GET. 307 and 308 preserve method and body. 303 supports retrieving a different resource after an operation.
Post/Redirect/Get reduces accidental form resubmission on refresh but does not replace duplicate-operation controls. Know the client redirect policy. Cross-origin redirects can restrict credentials and sensitive headers.
Chains add latency, and incorrect scheme information can create loops. Unvalidated returnUrl values create open redirects; validate local destinations or an allowlist. Permanent redirects can be cached and difficult to undo.
For login returns, form flows and HTTPS migrations.
Choosing 302 when a POST must be preserved.
One topic. Three levels of depth.
HTTP/1.1 301 Moved Permanently
Location: https://example.test/blogA permanent URL move.
This page does not send requests to external servers. Messages are readable HTTP/1.1 illustrations, not HTTP/2 or HTTP/3 wire dumps. example.test is reserved for examples. Run commands and JavaScript only in your own test environment; never publish real tokens or cookies.
Try it yourself first.
Which temporary redirect explicitly preserves PUT?
Show the solution and explanation
307 Temporary Redirect307 preserves method and body; destination trust remains a separate concern.