HTTP Redirects: 301 vs 302 and Debugging Chains
301 vs 302 vs 307, why long redirect chains are bad, and how to trace a URL to its final destination.
You click a link, and suddenly you're somewhere else. Behind the scenes, HTTP redirects are silently guiding your browser. But not all redirects are created equal, and redirect chains can kill your website's performance and SEO.
The Main Redirect Types
301 - Moved Permanently
This tells clients and search engines: "This page has moved permanently. Use the new URL from now on."
- Use for: Domain migrations, content consolidation, HTTPS enforcement
- SEO Impact: Google treats it as a strong signal that the new URL should be the canonical one
302 - Found (Temporary)
This tells clients and search engines: "This page is temporarily elsewhere. Keep using the original URL."
- Use for: A/B testing, maintenance pages, temporary promotions
- SEO Impact: Google treats it as a weak signal, so the original URL generally stays the canonical one
Other Status Codes
- 303 - See Other: Used after POST requests to redirect to a GET page
- 307 - Temporary Redirect: Like 302, but guarantees the request method won't change
- 308 - Permanent Redirect: Like 301, but guarantees the request method won't change
The Danger of Redirect Chains
A redirect chain occurs when URL A redirects to URL B, which redirects to URL C. Every hop adds latency:
example.com → www.example.com → https://www.example.com
Result: 2 extra round trips!Keep chains as short as you can, ideally a single hop. Crawlers follow only a limited number of hops (Googlebot generally follows 10) before giving up, and every extra hop adds latency for users.
Common Redirect Mistakes
- Using 302 for permanent moves: Sends a weak canonical signal, so the old URL can stay in search results
- Redirect loops: URL A → URL B → URL A (browser will error out)
- Mixed HTTP/HTTPS chains: Redirecting http → www → https instead of http → https directly
Redirect Implementation Methods
Server-Side Redirects
The most common method, implemented at the web server level:
- Apache (.htaccess):
Redirect 301 /old /new - Nginx:
return 301 /new; - Express.js:
res.redirect(301, '/new')
Meta Refresh
HTML-based redirect using a meta tag. Use it only when server-side redirects are not possible. Google interprets an instant (0 second) meta refresh as a permanent redirect and a delayed one as temporary:
<meta http-equiv="refresh" content="0; url=/new">JavaScript Redirects
Client-side redirects using JavaScript. A last resort: Google only sees them after rendering the page, and it warns that it might never see the redirect if rendering fails:
window.location.href = '/new';SEO Best Practices
- Use 301 or 308 for permanent moves: This tells search engines to treat the new URL as canonical
- Avoid redirect chains: Point every old URL straight at the final URL, ideally in one hop
- Update internal links: Don't rely on redirects for internal navigation - update links directly
- Monitor redirect health: Regularly check for broken redirects or chains
- Use canonical tags: For similar content, use canonical tags instead of redirects
Performance Impact
Each redirect adds latency to page loads:
- Single redirect: Adds one extra network round trip
- Redirect chain: Adds one round trip per hop, so the delay grows with every extra hop
- Mobile networks: Impact is even more significant due to higher latency
For optimal performance, minimize redirects and ensure they point directly to the final destination.
Common Redirect Scenarios
HTTP to HTTPS Migration
Essential for security. Redirect all HTTP traffic to HTTPS:
http://example.com → https://example.com (301)www vs. non-www
Choose one canonical version and redirect the other:
www.example.com → example.com (301)
or
example.com → www.example.com (301)Trailing Slash Normalization
Choose whether URLs end with a slash and redirect consistently:
example.com/page/ → example.com/page (301)Method Preservation: 301/302 vs. 303/307/308
HTTP semantics are defined in RFC 9110 (which obsoletes RFC 7231). The 308 status was first added by RFC 7538, which RFC 9110 has since folded in. The practical difference between the codes is what happens to a POST body when the client follows the redirect:
| Code | Permanence | POST becomes GET? |
|---|---|---|
| 301 | Permanent | Allowed to (most clients do) |
| 302 | Temporary | Allowed to (most clients do) |
| 303 | Temporary | Yes, the follow-up request is a GET |
| 307 | Temporary | No, method and body are kept |
| 308 | Permanent | No, method and body are kept |
301 and 302 date from the days when browsers rewrote POST to GET on redirect. The spec now says clients may do so for historical reasons, which is why 303, 307 and 308 exist to remove the ambiguity. The classic pattern is Post/Redirect/Get: a form handler answers a successful POST with 303 See Other so that refreshing the result page does not resubmit the form. Use 307 or 308 for API endpoints that must receive the original method and body at the new location.
Here is what curl does against a local test server that answers /post303 with a 303 and /post with a 307, both pointing at a page that logs the method it receives:
curl -s -o /dev/null -d x=1 -L http://localhost:8765/post303 # server sees: GET
curl -s -o /dev/null -d x=1 -L http://localhost:8765/post # server sees: POSTRedirects, Caching and Crawlers
Per RFC 9110, 301 and 308 responses are heuristically cacheable (302 and 307 are not unless the response says otherwise), so a browser may remember them and skip the server entirely next time. That is great for performance and painful when you get one wrong: a mistaken 301 can stick in users' caches long after you fix the server, and the only reliable cure is to avoid shipping it until you are sure. Test with 302 or 307 first, then promote to 301 or 308 once the target is final.
For search, Google's documentation describes 301 and 308 as permanent redirects that signal the target should be the canonical URL, and 302 and 307 as temporary ones that do not. It also says Googlebot generally follows 10 redirect hops, so a long chain is not just slow but can stop the crawler before it reaches the destination. Keep every redirect pointing straight at the final URL, and update internal links, sitemaps and canonical tags so crawlers rarely hit a redirect at all.
Open Redirect Vulnerabilities
A login page that sends users to ?next=/dashboard after sign-in is convenient, but if it redirects to whatever value it is given, an attacker can craft ?next=https://evil.example and borrow your domain's credibility in phishing emails. This is an open redirect.
- Prefer an allowlist: map short identifiers to known destinations instead of accepting URLs.
- If you accept paths, accept only paths: require a single leading
/and reject//host, backslashes and any value containing a scheme. - Compare after parsing: resolve the value with a URL parser and check the resulting origin equals your own, rather than pattern matching the raw string. The URL Parser shows how a string is split into scheme, host and path.
Tracing a Chain with curl
curl -sIL sends HEAD requests and follows each Location header, printing every hop. Against a test server where /old returns 301 to /new, which returns 302 to /final:
$ curl -sIL http://localhost:8765/old
HTTP/1.1 301 Moved Permanently
Location: /new
HTTP/1.1 302 Found
Location: /final
HTTP/1.1 200 OK
Content-Type: text/plain(Other headers such as Date trimmed.) To get a summary instead of headers, use -w:
$ curl -s -o /dev/null -L -w '%{num_redirects} %{url_effective}\n' http://localhost:8765/old
2 http://localhost:8765/finalA loop shows up as curl giving up at its redirect limit. With --max-redirs 5 against two URLs that point at each other, curl follows five hops, reports the last 302 and exits with code 47 (too many redirects). Some servers answer HEAD differently from GET, so if results look wrong, retry with curl -s -o /dev/null -D - -L to dump headers from real GET requests.
Related reading: HTTP Status Codes Explained for the full 3xx family, and Anatomy of a URL for how the pieces of a Location value are resolved.
Debugging Redirects
When a page isn't loading correctly, or you're investigating an SEO issue, you need to see the full redirect chain. Common problems include:
- Too many redirects: Chains of more than one hop
- Redirect loops: A redirects to B, B redirects back to A
- Mixed protocols: HTTP and HTTPS redirects in the same chain
- Wrong status codes: Using 302 for permanent moves
- Broken final destination: Redirect chain ends at a 404 or error page
Our URL Redirect Checker follows the chain from our server and lists each hop with its URL, status code and Location header, then the final URL. It stops after 10 hops. This helps you:
- Spot chains, loops and mixed HTTP/HTTPS hops
- Fix broken or inefficient redirects
- Ensure redirects are SEO-friendly (using correct status codes)
- Verify redirect destinations are correct
Because the request comes from our server, it sees what an anonymous visitor sees. Redirects that depend on your cookies, login or location can differ, so use curl as shown above for those.
Frequently Asked Questions
What is the difference between a 301 and a 302 redirect?
A 301 says the move is permanent, so browsers may cache it and search engines should treat the new URL as canonical. A 302 says the move is temporary and the original URL should stay in use.
Should I use 307 or 308 instead of 302 or 301?
Use them when the request method and body must survive the redirect, such as API calls with POST or PUT. For ordinary page navigation with GET, 301 and 302 behave the same in practice.
Why do I get "too many redirects" in my browser?
Almost always a loop: two rules send the request back and forth, such as a server forcing HTTPS while a CDN or proxy talks to it over HTTP. Trace the hops and look for a URL that repeats.
Do redirects hurt SEO?
A single correct 301 is the standard, supported way to move a page. Problems come from chains, loops, temporary codes used for permanent moves, and redirects that end in a 404.
Written by Kashyap Thakar
Spotted a mistake? Let me know
Try these tools
Use these tools alongside this guide