Redirect chains and loops: what they are and how to fix them
What is a redirect chain?
It's a redirect that leads to another redirect. A visitor asks for page one. The server sends them to page two. Page two sends them on to page three. Google describes it as a "chain" of multiple redirects1.
Chains usually grow by accident. You redirect an old address after one rebuild, then rebuild again and add a second rule, and the first rule still points at the middle address.
Is a chain a problem?
A small one. Google says Googlebot can follow up to 10 hops in a chain, but it advises redirecting to the final destination directly1. If that's not possible, Google says to keep the number of redirects in the chain low, ideally no more than 3 and fewer than 51.
The reasons it gives are plain. Chaining redirects adds latency for users, and not all user agents and browsers support long redirect chains1. Latency is just waiting time. A user agent is the software, usually a browser, that asks for the page.
So a chain won't usually break anything, but it slows people down and gives some browsers a reason to stop.
How do I fix a chain?
Point every old address at the final page. Say the old address goes to a middle address, and the middle address goes to the final page. Change the first rule so it goes straight to the final page.
Work through it in this order:
- List where each old address ends up. The page on checking redirects shows how to follow the hops.
- Find any rule whose destination is itself redirected.
- Change that rule's destination to the final address.
- Test again.
Also fix your own links. MDN says to correct internal links and avoid internal redirects where you can2.
What's a redirect loop?
A loop is a chain that never ends. MDN says redirection loops happen when additional redirections follow the one that has already been followed. No page is ever found2.
The simplest case is two rules pointing at each other. Address A sends visitors to B, and B sends them back to A. A subtler one is a rule that sends the plain address to the secure one while another sends the secure one back to the plain one.
Why does my page say "too many redirects"?
"Too many redirects" is a general way of describing the error, not wording MDN uses. There are two cases.
In the first, the server spots the loop itself. MDN says most of the time this is a server problem, and if the server can detect it, it will send back a 500 Internal Server Error. MDN adds that if you see such an error soon after modifying a server configuration, it's likely a redirection loop2.
In the second, the server can't spot the loop. MDN says browsers detect it and show their own error message. It quotes Firefox as saying it has detected that the server is redirecting the request for this address in a way that will never terminate. Chrome shows "This Webpage has a redirect loop"2.
Either way, think about what you changed last. A new rule, a switch in your host's dashboard, or a plugin setting are common starting places. This is general advice, so read your platform's own help pages for where redirects are set.
Could the problem be on my side as a visitor?
Occasionally. MDN says that the user can't do much, unless corruption is happening on their side, like a mismatch of cache or cookies2. If you're the site owner and only one browser shows the error, try another browser or a private window before you edit anything.
Why do loops sometimes come from two kinds of redirect?
A page can be redirected in more than one way: by the server, by a <meta> tag in the page, or by JavaScript. MDN warns that if someone changes the HTTP redirects but forgets to change the HTML redirects, the two will no longer match, which could cause an infinite loop2.
So use one method. MDN's advice is to prefer server redirects and not add <meta> ones on top2. Check your site for old redirect plugins or leftover tags if a loop appears after a change of tools.
How do I stop a test from running forever?
When you test with the command line tool curl, it stops after a set number of redirects. The curl manual says the limit is set to 50 redirects by default3. You can lower it with the --max-redirs option, and the manual's own example uses curl --max-redirs 3 --location https://example.com3.
Setting a low limit on a test lets a loop fail fast. Then you can see which address it keeps returning to.
Further reading and sources
- Site moves with URL changes, Google Search Central
- Redirections in HTTP, MDN Web Docs (Mozilla)
- curl manual page, curl project