How to check a redirect chain

A redirect chain is a URL that redirects to a URL that redirects again. Each hop adds a round trip, and long chains can lose visitors and crawlers. Here is how to see every hop.

1. One URL: every hop

curl -sL -o /dev/null -D - --max-redirs 10 http://wikipedia.org | grep -iE '^(HTTP/|location:)'

Output for wikipedia.org:

HTTP/1.1 301 Moved Permanently
location: https://wikipedia.org/
HTTP/2 301
location: https://www.wikipedia.org/
HTTP/2 200

Two hops: http to https, then to www. Each status line is one response; the location under it is where it sends you next. gmail.com, for comparison, goes through three redirects before a page answers 200.

Use GET, not curl -I. -I sends HEAD requests, and some servers answer HEAD differently: in our test bit.ly redirected to bitly.com, which answered HEAD with 405 but GET with 200. The command above uses GET and throws the body away.

2. A list of URLs

One URL per line in urls.txt, then:

printf 'hops\tstatus\turl\tfinal\n' > redirects.tsv
while read -r url; do
  curl -sL -o /dev/null --max-redirs 10 -w "%{num_redirects}\t%{http_code}\t$url\t%{url_effective}\n" "$url" >> redirects.tsv
done < urls.txt
cat redirects.tsv

Our test output:

hops  status  url                    final
2     200     http://wikipedia.org   https://www.wikipedia.org/
1     200     http://github.com      https://github.com/
1     200     http://bit.ly/         https://bitly.com/
0     200     https://example.com/   https://example.com/

Open redirects.tsv in a spreadsheet and sort by hops. If a URL redirects more than 10 times, curl stops with curl: (47) Maximum (10) redirects followed, which usually means a redirect loop.

3. How to fix a chain

Every URL in a sitemap, with the full chain

Our Sitemap URL Status Checker on Apify takes sitemaps or a plain list of URLs and returns, per URL, the status, the full redirect chain, the hop count and the final URL, and flags chains of more than one hop, as CSV, Excel or JSON. Billed per URL.

Frequently asked questions

How many redirects are too many?

Aim for at most one. Google follows up to 10 hops, but each hop adds a delay, and every chain is a sign that links or redirects were not updated.

Is a 301 or 302 better?

301 (or 308) for permanent moves; 302 (or 307) only for temporary ones.

Why does curl -I show an error but the page works in my browser?

curl -I sends HEAD requests, and some servers answer HEAD with 405 or 404. Check with a GET request, as in the commands on this page.

How do I find a redirect loop?

curl stops after its redirect limit with error 47. Run the hop command with --max-redirs 10 and read the location lines: the same URLs repeat.

Written with AI assistance. The curl commands and the bulk loop were run on 2026-10-01 against wikipedia.org, github.com, bit.ly, gmail.com and example.com. The Apify tool is ours; the APIs are free to call directly.