07887 423199me@richieaubin.com

Choose the right redirect status code

Choose the code by asking two questions. Is the move permanent? Must the client keep the same request method and body when it follows the redirect?

Redirect status choice example
Example image · CC0 1.0 licence

Choose a way to do this check

Browser Network

  1. Load the old address with Preserve log enabled.
  2. Record the first status and the Request Method shown for the following request.

Screaming Frog List mode

  1. Check the first status across your approved URL list.
  2. For POST preservation, switch to a harmless staging fixture that can echo the method and discard the body.

Read a response here

  1. Paste the header block with its status line and Location.
  2. Classify 301 and 308 as permanent, 302 and 307 as temporary, then check method requirements separately.

1. Decide whether the change will last

Use a permanent redirect for a page with a lasting replacement. Use a temporary redirect when the original URL should remain the intended entry point, such as during a short-lived change. A lasting page move usually needs updated internal links, canonicals and sitemap entries as well as the redirect.

Status 301 is permanent and 302 is temporary. When following either, a client is allowed to change a POST to GET. Status 308 is permanent and 307 is temporary. Clients that automatically follow them must keep the method. This distinction matters for forms and APIs, where a request may also carry a body.

2. Test an ordinary page redirect

The Nginx example is a temporary move for an ordinary public page. Add it to the appropriate server block, replace both addresses and run nginx -t before reloading through your normal process. Use 301 for a permanent replacement when you do not require method preservation, or 308 when both permanence and method preservation are required.

Nginx server block · temporary public-page move
location = /opening-hours/ {
    return 302 https://www.example.com/temporary-hours/;
}

Use a fresh GET to inspect the first response. Follow it separately to check that the final page is accessible and useful. Both the status and the destination must match the situation. If a test returns a permanent redirect but the move is temporary, confirm which rule or CDN layer answered first.

Terminal · inspect a redirect without following it
curl -sS -D - -o /dev/null \
  https://www.example.com/opening-hours/

3. Verify the method using a non-mutating test endpoint

A redirect from a form or API can replay a request. Test against a staging endpoint designed to echo the received method and discard the body. Use fictional data. Set up the source to return the expected 307 or 308 to that echo endpoint before running the example. Do not perform this test against a real booking, payment or submission endpoint.

Terminal · test a method-preserving redirect on staging
curl -sS -L --max-redirs 3 \
  --data 'sample=verification-only' \
  https://staging.example.com/method-test/

Look for the method and sample data at the final test endpoint. Avoid forcing the method with curl -X POST, because it can keep POST across redirects where the client would normally switch to GET. Confirm that the redirected location belongs to the expected host, especially when a request contains credentials or data.

4. Verify deployment and rollback

Test one matched URL and one route that should stay unchanged. Check whether a CDN retains the earlier redirect, and follow the normal cache invalidation process if needed. When the move ends, remove the temporary rule and confirm the original URL serves the expected response again. If a change causes clients to reach the wrong destination, roll back the rule and check fresh requests.

Technical references

Frequently asked questions

Which code should I use for a permanent page move?

301 is common for an ordinary page move. Use 308 if clients must preserve the method when following it.

What is the difference between 302 and 307?

Both are temporary. A client can switch POST to GET after 302, while a followed 307 preserves the method.

Can I infer what happens from a HEAD request?

Not always. Test the intended method and use a harmless fixture for requests that could otherwise change data.

Should I update the sitemap for a short-lived redirect?

Keep the longer-term intended URLs in mind. For a permanent move, update the sitemap to list the final address.

Written by Richie Aubin

Published