301, 302, 307 or 308: choosing the right redirect

Permanent or temporary, what each means for your search rankings, and how to find redirect chains and loops.

Cover image for 301, 302, 307 or 308: choosing the right redirect

A redirect sends visitors and search engines from one URL to another. Pick the right type and a moved page keeps its search rankings. Pick the wrong one, or chain several together, and you can lose traffic without noticing.

The four status codes

Code Meaning Use it when
301 Moved permanently A page or site has moved for good.
308 Permanent redirect The same, when the request method must be kept (a form POST stays a POST).
302 Found, a temporary redirect A page is somewhere else for now and will come back.
307 Temporary redirect The same as 302, with the method kept.

For ordinary web pages, 301 and 308 behave the same in browsers, and so do 302 and 307. The difference only matters for forms and APIs.

Permanent or temporary: what search engines do

A permanent redirect tells Google the new URL replaces the old one. Google moves the old page's ranking signals to the new address and, over time, shows the new URL in its results.

A temporary redirect says the old URL is still the real one, so Google keeps showing it. If a "temporary" redirect stays in place for a long time, Google may eventually treat it as permanent anyway, but there's no reason to rely on that. If a move is permanent, say so with a 301.

Typical uses for a 301:

  • Moving from http:// to https://.
  • Choosing between www.example.com and example.com, and redirecting the other one.
  • Changing a page's URL, or merging two pages into one.
  • Moving to a new domain.

Typical uses for a 302:

  • A product that's out of stock for a while, sending people to its category.
  • A short-lived maintenance or event page.

Chains and loops

A redirect chain is a redirect that leads to another redirect: http://example.com to https://example.com to https://www.example.com to https://www.example.com/home. Each hop adds a delay for visitors, and Google's crawler stops following after about ten. Point every old URL straight at its final destination.

A redirect loop is a chain that comes back to a URL it has already visited. Browsers give up and show an error. Loops usually come from two rules fighting each other, such as one adding www and another removing it, or a plugin and the server both forcing HTTPS in different ways.

Redirects that aren't really redirects

Some pages redirect with a meta refresh tag or with JavaScript. Search engines usually follow them, but they're slower, and weaker signals than a proper status code from the server. Use a server redirect whenever you can.

Check your redirects

The URL redirect checker follows a URL hop by hop, up to ten, and shows each status code, so you can spot chains, loops and temporary redirects that should be permanent. Try it on the four versions of your home page, with and without www, on both http:// and https://. All four should end at the same URL, in one hop at most. To see every header of the final response, use the HTTP headers lookup.