跳到主要内容
EnglishEN EspañolES FrançaisFR DeutschDE ItalianoIT PortuguêsPT 中文ZH 日本語JA 한국어KO РусскийRU NederlandsNL
← Back to all articles

本文目前仅提供英文版本。

301 vs 302 Redirects: Which to Use and How to Fix Redirect Chains

Every website collects redirects. A page gets renamed, a service is retired, the site moves from http to https, or a whole domain changes. Each time, an old URL has to send visitors and search engines somewhere new, and the status code you choose tells them whether the move is for good or just for now.

Pick the wrong one and Google may keep showing the old URL in search results. Stack redirects on top of each other for a few years and you end up with chains that slow pages down and, in the worst case, loops that break them. This guide explains the difference between 301, 302, 307 and 308 redirects in plain English, how Google treats each one, what it says about chains, and how to clean them up.

Key facts

  • 301 / 308 — Permanent redirects: Google treats the target as the canonical URL
  • 302 / 307 — Temporary redirects: Google doesn't treat the target as canonical
  • 10 — Redirect hops Google's crawlers follow by default before giving up
  • 1 year — How long Google generally advises keeping redirects after a site move, at minimum

Permanent vs Temporary: What the Codes Mean

A redirect is an HTTP response with a status code in the 3xx range and a Location header that points to the new URL. The browser or crawler requests the old URL, gets the redirect, and then requests the new one. MDN groups the common codes into two families:

  • Permanent: 301 Moved Permanently and 308 Permanent Redirect. The old URL is gone for good and the new one replaces it.
  • Temporary: 302 Found, 303 See Other and 307 Temporary Redirect. The old URL is still the real address; visitors are just being sent elsewhere for now.

Why 307 and 308 exist

The older codes, 301 and 302, are ambiguous about form submissions. MDN notes that with a 301 or 302, a GET request stays a GET, but other methods such as POST "may or may not be changed to GET". The 307 and 308 codes were created to remove that ambiguity: the method and body are never changed.

For ordinary pages that people and crawlers load with GET, a 301 and a 308 behave the same, and so do a 302 and a 307. Google's crawler documentation says the same: it describes 308 as equivalent to 301 and 307 as equivalent to 302. The newer codes matter mainly when a redirect sits in front of a form handler or an API endpoint.

How Google Treats Each Type

Google's guide to redirects is clear on the main difference. When Google sees a permanent redirect, its indexing pipeline uses it as a signal that the target URL should be the canonical one, which is the version shown in search results. With a temporary redirect, it doesn't use the redirect as that signal, so the old URL is more likely to stay in results.

Google's crawler documentation describes a 301 as a "strong" signal and a 302 as a "weak" one. That doesn't mean a 302 loses ranking value. Google's site-move guide states that "301 and other permanent redirects don't cause a loss in PageRank", and the issue with a 302 is simply which URL Google chooses to show. Google may also keep the old URL as an alternate name for the new one, so people searching for an old address still find you.

Which one to use

  • Use a 301 (or 308) when a page has moved for good: a renamed URL, merged pages, a switch to https, a new domain, or a change between www and the bare domain.
  • Use a 302 (or 307) when the move really is temporary: a page down for maintenance, a short promotion, or sending visitors to a different page while the original is being rebuilt.

Google recommends server-side permanent redirects whenever possible. A common mistake is leaving a 302 in place for months after a permanent change, often because a plugin or hosting panel used 302 as its default.

Server-Side vs Meta Refresh vs JavaScript

Redirects don't have to come from the server, but the server is the best place for them. MDN explains that HTTP redirects always run first, JavaScript redirects run next, and an HTML meta refresh runs only if neither of the others did. Its advice is to use HTTP redirects when possible.

Google treats the alternatives this way:

  • Meta refresh: an instant refresh (content="0; url=...") is treated as a permanent redirect; one with a delay is treated as temporary.
  • JavaScript: Google says to use JavaScript redirects only if you can't do server-side or meta refresh redirects, because if rendering fails it might never see the redirect.
  • "We moved" links: a page that just says the content has moved and links to it is not a reliable way to tell search engines anything. Google says not to rely on it unless you have no other choice.

Examples

On an Apache host with .htaccess, Google's documentation shows both mod_alias and mod_rewrite forms:

Redirect permanent "/old-page/" "/new-page/"
RewriteRule "^old-page/?$" "/new-page/" [R=301,L]

Note that Apache's plain Redirect directive sends a 302 unless you add permanent or a code. In PHP, send the status before the header:

header('HTTP/1.1 301 Moved Permanently');
header('Location: https://www.example.com/new-page/');
exit;

If your site sits behind Cloudflare, its Single Redirects rules support 301, 302, 307 and 308, with 301 as the default. Preserving the query string is off by default, so switch it on if your old URLs carry parameters you need to keep.

Redirect Chains and Loops

A redirect chain is when one redirect leads to another: http://example.com/services goes to https://example.com/services, then to https://www.example.com/services, then to https://www.example.com/services/. Each hop is another round trip before the page starts to load.

Google's site-move guide is direct: "Avoid chaining redirects." Googlebot can follow up to 10 hops, but Google advises redirecting to the final destination directly, and if that isn't possible, keeping chains short, "ideally no more than 3 and fewer than 5". It adds that chains add latency for users and that not all browsers support long chains. For robots.txt the limit is stricter: Google follows at least five hops and then treats the file as a 404.

A redirect loop is a chain that never ends, for example page A redirects to page B and page B redirects back to A. Browsers stop and show an error, so the page simply doesn't load for anyone. Loops often appear when two systems both enforce a rule, such as a CMS forcing www while the host or CDN forces the bare domain.

How chains build up

  • Old redirects pointing to URLs that were later redirected again.
  • Separate rules for https, www and trailing slashes that run one after another instead of in a single step.
  • Internal links, menus and sitemaps still using old URLs, so every click starts with a redirect.

How to Audit and Fix Your Redirects

  1. List your redirects. Collect them from .htaccess, your CMS or plugin, your hosting panel and your CDN. Rules in more than one place are where conflicts and loops start.
  2. Test the chain for each important URL. Running curl -sIL https://example.com/old-page in a terminal prints every hop with its status code. Google's URL Inspection tool in Search Console also shows which URL Google considers canonical.
  3. Point every redirect at the final URL. If A goes to B and B goes to C, change A to go straight to C. Combine your https, www and trailing-slash rules so any variant reaches the final address in one hop.
  4. Swap 302s for 301s wherever the change is permanent.
  5. Update internal links, navigation, canonical tags and your XML sitemap to use final URLs. Google's site-move guide asks you to change internal links to the new URLs, and a sitemap should only list URLs that return 200.
  6. Redirect to relevant pages. Google warns against sending many old URLs to one unrelated page such as the home page, which it may treat as a soft 404. If there's no good match, a real 404 or 410 is more honest.
  7. Keep redirects in place. Google's advice after a site move is to keep them "for as long as possible, generally at least 1 year", and from users' point of view to consider keeping them indefinitely, because old links in emails, bookmarks and other sites keep working.

Sources

Related reading

Frequently asked questions

Does a 302 redirect hurt SEO?

Not in the sense of losing value. Google says permanent redirects don't cause a loss in PageRank, and the difference with a 302 is that Google doesn't treat the target as the canonical URL, so the old address may keep appearing in search. If the move is permanent, use a 301.

Should I use 301 or 308?

For normal pages either works: Google treats 308 the same as 301. A 308 guarantees the request method isn't changed, which matters for forms and APIs that receive POST requests.

How long should I keep a 301 redirect?

Google advises keeping redirects after a site move for as long as possible, generally at least a year, and suggests considering keeping them indefinitely for users. Removing them breaks old links and bookmarks.

Redirects and URLs giving you trouble?

Tell me about your site and I'll send a free, no-obligation quote for a clean technical SEO setup, redirects included.

Get a free quote