Redirect Chains and Loops: Spotting and Fixing Them
Two things go wrong with redirects, and they feel different. A chain is slow. A loop is stuck. If a page shows an error about too many redirects, you have a loop.
What a loop looks like on screen
You type the address and the page never arrives. After a pause, the browser stops and shows a message. Firefox says the server is redirecting the request in a way that will never end. Chrome says the page has a redirect loop.1
The tab might spin for a moment first. That's the browser hopping between addresses before it quits.
MDN defines a loop as extra redirects that keep following the one already followed, so no page is ever found.1
What it tells you
A loop means two or more rules disagree. A classic case: one rule sends the plain address to the version with www, and another rule, in a different place, sends www back. Each rule looks fine alone. Together they chase each other.
MDN gives a useful clue. If the error appears soon after you change a server configuration, a redirect loop is the likely cause.1 So think about what you changed last.
Sometimes the server spots the loop and shows its own error instead. Sometimes it doesn't, because the loop spreads across several servers, each seeing only its own part. Then the browser notices.1
Whose fault is it?
MDN says a visitor can't do much, unless something on their side is wrong, such as cache or cookies that don't match.1 If the page still fails for other people and other browsers, the fault is on the site, so look at your redirect rules.
Finding the rule that causes it
- Write down the starting address and the address it ends up at.
- Follow each hop, one at a time, using the curl steps in this guide to checking. Note the code and the destination at each stop.
- Look for an address that appears twice. That's the loop.
- Find every place that can redirect that address: the server file, the website's settings, a plugin, the host's control panel. The usual places are listed in where redirects are set up.
- Remove or change one of the two rules so they no longer point at each other.
Your own redirect list helps here. If a new address also appears in the old-address column, you've built a loop or a chain on paper.
Chains: slow but not stuck
A chain is page one to page two to page three. It works, but it's slower. Google says to avoid chaining redirects and to send each old address straight to the final one.2
Google also gives numbers. Its crawler can follow up to 10 hops. If you can't avoid a chain, it advises keeping the count low, ideally no more than 3 and fewer than 5. Long chains add delay for users, and not all browsers support them.2
The fix is simple to say. For each hop in the middle, change the first rule so it points at the final address. Then the middle address can stay as its own redirect for any links still using it.
Cited material
- Redirections in HTTP, MDN Web Docs
- Site move with URL changes, Google Search Central