Zum Hauptinhalt springen

Guides / http-status-codes

301 vs 302: permanent and temporary redirects

A 301 says the resource has moved permanently and the new URL should replace the old one everywhere; a 302 says the move is temporary and the original URL is still the real one. Search engines act on that difference, which is why the wrong code costs you rankings.

What the two codes tell a client

Both codes send the client to the address in the Location header, and to a visitor they look identical. The difference is what everything else does with the information. A 301 invites clients and crawlers to update their records: replace the bookmark, rewrite the link, index the target instead of the source. A 302 asks them to keep using the original URL and just take a detour this time. Browsers may cache a 301 and stop asking the server at all; a 302 is not cacheable by default unless the response says otherwise.

When to use which

  • Use 301 for a domain change, an HTTP to HTTPS migration, a non-www to www canonicalization, a permanent URL restructure, a merged or renamed page, or a retired product page pointing at its closest replacement.
  • Use 302 for a maintenance page, an A/B test, a geographic or language landing choice you may change, a short-lived campaign URL, or a temporary "come back later" destination.

Never use a 301 for something you intend to reverse. Because clients cache it, returning visitors can keep landing on the temporary destination long after you delete the rule, and there is no way to reach into their caches. The opposite mistake: leave a 302 on a permanent move and the old URL stays indexed, the new one competes with it, and the signals stay split.

SEO consequences

Google's documentation states that a permanent redirect is a signal that the redirect target should be treated as the canonical URL, while a temporary redirect is not, so the original URL keeps its place in the index. In practice:

  • A 301 consolidates link equity onto the target and, over time, replaces the old URL in the index with the new one.
  • A 302 generally leaves the source URL indexed. Search engines do try to interpret intent, so a long-lived 302 may eventually be treated as permanent, but you should not rely on being guessed correctly.
  • Redirect chains dilute the benefit and slow crawling. Point old URLs directly at the final destination.
  • Redirecting many retired pages to the home page tends to be treated as a soft 404 rather than as a move. Redirect to the closest equivalent page, or return a 410 if nothing is equivalent.
  • Whatever you choose, keep it consistent with your canonical tags and your sitemap. Contradictory signals are worse than a slightly suboptimal one.

307 and 308: the method-preserving versions

The original definitions of 301 and 302 were ambiguous about the HTTP method, and clients settled on a behavior the standard now describes as historical: when following a 301 or 302 after a POST, many clients change the method to GET and drop the body. For a page that is harmless. For a form endpoint or an API it destroys the request and reports nothing.

307 Temporary Redirect has the same meaning as 302, and 308 Permanent Redirect has the same meaning as 301, with one requirement added to both: the method and body must be preserved. So for URLs that only ever receive GET requests, 301 and 302 are fine and are what most tooling expects. For anything that accepts POST, PUT, PATCH or DELETE, use 308 for a permanent move and 307 for a temporary one. If you specifically want a POST to be followed by a GET on another URL, that is what 303 See Other is for.

How to check which code a URL returns

  1. Read the status line and the target without following the redirect:
    curl -sI https://example.com/old-page | grep -Ei "^(HTTP|location|cache-control)"
    The status line shows 301, 302, 307 or 308, and Location shows where it points.
  2. Follow the whole chain and count the hops, so you can see whether one redirect has become three:
    curl -sIL -o /dev/null -w "%{num_redirects} hops, final %{http_code}, %{url_effective}\n" https://example.com/old-page
  3. Test with a POST if the endpoint accepts one. If the request arrives at the target as a GET with no body, switch the rule to 307 or 308.
  4. Change the code where it is generated. This may be the application, the web server config, an .htaccess rule, or the CDN. If two layers both redirect, the outermost one wins and the inner rule is invisible.
  5. Verify with a cold cache. A browser that already cached a 301 keeps obeying it, so confirm with curl or a private window before deciding the change did not take.
  6. After a permanent move, keep the redirect in place. Removing it later strands every link and bookmark that still points at the old URL.

Watching a redirect after you set it

A redirect that changes code, starts looping or loses its TLS certificate leaves the source URL still responding, so nothing looks broken until traffic falls. External checks that record the exact status code and follow the chain surface that on the next run, and running them from many networks distinguishes a global rule change from a regional CDN issue. HostTracker has been monitoring websites since 2004 and runs checks from 300+ checkpoints in 158 cities. See what a URL returns right now with the HTTP check tool, and read the full 3xx redirection family guide for the codes either side of these two.

Check it now

Run the free check against your own site - no account needed.

HTTP check

Monitor this permanently

Get alerted the moment it breaks: HostTracker checks from 300+ locations and notifies you by email, SMS, Slack, Telegram and more.

HostTracker features