Prompt
How do I find redirect chains and loops on a site?
Latest observation
To find redirect chains and redirect loops on a site, you can use a mix of browser tools, command-line tools, crawlers, and logs.
1) Quick manual checks with curl
Use curl to inspect the redirects step by step:
curl -I -L https://example.com
-I= headers only-L= follow redirects
If you want to see each hop clearly:
curl -v -I https://example.com
Look for:
HTTP/1.1 301,302,307,308Location:header- Repeated URLs or a cycle
Example of a chain
http://example.com -> https://example.com
https://example.com -> https://www.example.com
https://www.example.com -> /home
Example of a loop
http://example.com -> https://example.com
https://example.com -> http://example.com
2) Use a website crawler
Tools like these can crawl the site and report redirect issues:
- Screaming Frog SEO Spider
- Sitebulb
- Ahrefs / Semrush site audits
- Chrome DevTools + crawl extensions
In Screaming Frog:
- Crawl the site
- Check:
- Response Codes
- Redirection (3xx)
- Redirect Chains
- Redirect Loops
This is one of the easiest ways to find sitewide issues.
3) Check redirect chains in Chrome DevTools
Open the site in Chrome:
- Press F12 → Network
- Reload page
- Click the document request
- Look at the Headers and the sequence of requests
You can see each redirect hop, status code, and destination.
4) Use online redirect checkers
For a single URL, tools like:
- Redirect-checker.org
- httpstatus.io
- WhereGoes
These show:
- Full redirect chain
- Status codes
- Final URL
- Whether a loop exists
5) Find loops programmatically
If you want to scan many URLs, write a small script.
Python example
import requests
def check_redirects(url, max_hops=10):
seen = []
current = url
for i in range(max_hops):
try:
r = requests.get(current, allow_redirects=False, timeout=10)
except requests.RequestException as e:
return {"error": str(e), "chain": seen}
seen.append((current, r.status_code, r.headers.get("Location")))
if r.status_code not in (301, 302, 303, 307, 308):
return {"final": current, "chain": seen}
next_url = r.headers.get("Location")
if not next_url:
return {"error": "Redirect without Location header", "chain": seen}
# Detect loop
if next_url in [x[0] for x in seen]:
return {"error": "Redirect loop detected", "chain": seen}
current = requests.compat.urljoin(current, next_url)
return {"error": "Max hops exceeded", "chain": seen}
6) Inspect server or CDN logs
If you control the site:
- Web server logs (Nginx/Apache)
- CDN logs (Cloudflare, Fastly, Akamai)
- App logs
Look for repeated requests for the same resource with 3xx responses.
This is useful when loops happen only for certain:
- User agents
- Cookies/sessions
- Geographic regions
- HTTP vs HTTPS
- www vs non-www
- trailing slash rules
7) Common causes of redirect loops
These often create chains or loops:
- HTTP ↔ HTTPS misconfiguration
- www ↔ non-www conflict
- trailing slash normalization
- locale/language redirects
- login/session redirects
- CDN redirects + origin redirects both applied
- mixed rules in
.htaccess, Nginx, app router, and CDN
8) Best practice
A good redirect setup should:
- Use one redirect per hop
- End at the final canonical URL quickly
- Avoid bouncing between multiple layers
- Keep chains to 0–1 redirects when possible
If you want, I can also give you:
- a bash script to scan a list of URLs for loops/chains, or
- a Python script that exports results to CSV.