toolfree

301 Moved Permanently

What a 301 redirect means, how it differs from 302, 307 and 308, and why a redirected POST can arrive as a GET.

Runs in your browser

Click a code to copy it.

3xx · Redirection

What you asked for is somewhere else, or has not changed.

CodeMeaning
Moved PermanentlyIt has moved for good. Update your links.A 301 or 302 permits a client to turn a POST into a GET on the redirect, and browsers do. Use 308 or 307 if the method must survive.
FoundIt is temporarily somewhere else. Keep using this address.
See OtherGo and GET this other address instead — the usual reply to a completed form.
Not ModifiedYour cached copy is still good. No body is sent.
Temporary RedirectTemporarily elsewhere, and the method must not change.
Permanent RedirectPermanently elsewhere, and the method must not change.

What it says

A 301 says the resource has moved for good and that you should update anything pointing at the old address. The new one is in the Location header.

Search engines act on that: they move the ranking signals to the new URL and eventually replace it in the index. That is why 301 is the redirect you want when a site changes domain or restructures its paths.

The method problem

This is the part that bites, and it is not widely known.

301 and 302 permit the client to change the method. A POST followed to a 301 may be re-sent as a GET, without the body. The specification allows it for historical reasons, and browsers do it. So redirecting a form submission through a 301 silently loses the submission.

307 and 308 forbid it. They mean exactly what 302 and 301 mean, with the added guarantee that the method and body survive the redirect.

CodePermanent?Method preserved?
301YesNo
302NoNo
307NoYes
308YesYes

The rule is simple: if the request might be a POST, use 307 or 308.

303 is the deliberate opposite

303 See Other tells the client to go and GET a different address, changing the method on purpose. It is the correct reply to a completed form: the browser lands on a result page it can safely refresh, instead of being asked to resubmit.

Caching, and why 301 is hard to take back

Browsers cache permanent redirects, often indefinitely and sometimes without revalidating. A 301 pointing at the wrong place can persist in a visitor’s browser long after you fix the server, and you cannot clear it remotely.

Test redirects with a 302, then change to 301 when you are sure. Going the other way is much more painful than it sounds.

Chains

Every hop costs a round trip, and both browsers and crawlers give up after several. Redirect straight to the final address rather than through two intermediate rules — and check what your host adds, since HTTP-to-HTTPS and apex-to-www often add hops you did not write.