Practical developer guides

HTTP redirects: which codes preserve the request method

Choose 303, 307 or 308 deliberately and inspect how 301 and 302 affect POST requests.

Nav Tools ·

Choose the redirect behavior

A 303 directs the client to retrieve another resource, usually with GET. It is commonly used after a successful form submission.

A 307 or 308 preserves the method and content when following the redirect. This distinction matters for uploads and API writes.

POST /submit → 303 Location: /result → GET /result
POST /upload → 307 Location: /new-upload → POST /new-upload

Do not assume POST survives 301 or 302

HTTP allows common historical behavior where a client changes POST to GET after 301 or 302. Libraries can expose their own redirect controls.

Use 307 or 308 when preserving the method is required, and test the clients that actually call the endpoint.

Temporary and permanent are separate choices

307 is temporary and 308 is permanent. Permanence influences caching and future use of the target, not just the current request.

Avoid deploying a permanent redirect as a casual test when you expect to switch the endpoint back shortly.

Inspect the destination and credentials

A redirect can cross origins or schemes. Clients may remove sensitive headers, refuse a redirect or require replayable request bodies.

Inspect the final URL and chain. A converter producing code does not guarantee that a redirected request sends identical credentials in every runtime.

References

← Practical developer guides