Checked
2026-11-14
/ Redirect loop

Too many redirects: two rules send visitors in a circle

The browser followed redirects until it gave up, about twenty in a row. Somewhere two rules disagree: one sends http to https and another sends it back, or www and the bare domain point at each other.

See the loop

Run the free redirect checker on the address, or ask curl, which prints every hop:

curl -sIL --max-redirs 10 http://example.com | grep -i -E '^(HTTP|location)'

Read the location lines. If they swap between http and https, it is an https rule. Between www and the bare domain, it is a hostname rule. The same address over and over usually means the app redirects to itself, often because it believes the visit came in over http.

If curl shows no loop and your browser does, clear the site's cookies or try a private window. Browsers cache 301 redirects, and a cookie can cause a loop for one visitor only.

The usual causes

  • A CDN in Flexible SSL mode. Cloudflare's Flexible mode talks to your server over plain http, your server redirects to https, and the CDN asks over http again. Switch to Full or Full (strict), with a valid certificate on the server, or drop the server's own redirect.
  • A proxy or load balancer that ends https and talks http to the app. The app sees http and redirects. Pass the scheme on with proxy_set_header X-Forwarded-Proto $scheme; and have the app read it.
  • WordPress with home and siteurl on http while the server forces https, or the other way round. wp option get home and wp option get siteurl show both; they must match the address you want, scheme included.
  • Two www rules pointing opposite ways, one in the web server and one in the CDN or the app. Pick one address and keep a single rule for it.
  • A redirect plugin or an .htaccess rule that matches its own target. Switch it off and test again.

WordPress behind a proxy

WordPress decides whether a visit is https from what PHP sees. Behind a proxy that ends https, add this near the top of wp-config.php so WordPress takes the proxy's word for it:

if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
    && strpos( $_SERVER['HTTP_X_FORWARDED_PROTO'], 'https' ) !== false ) {
    $_SERVER['HTTPS'] = 'on';
}

Add it only when a proxy you control sets that header.

What not to do

  • Do not add another redirect to fix a redirect loop.
  • Do not turn on HSTS while a loop is live. Browsers then remember the https rule for as long as the header says, often a year.
  • Do not test only in your own browser. It has the old redirects cached; curl and a private window show what a new visitor gets.

When to stop and hand it over

Stop if the loop runs through a CDN, a load balancer and the app together, or a panel you did not set up, and each change seems to move the loop somewhere else. Our Server Rescue is one incident at a fixed $69, with a same-day start listed at $109, and nothing to pay if we cannot fix it.

/ Questions

Questions people ask

Why does it work in one browser and not another?
Redirects and cookies are cached per browser. Clear the site's cookies, or use a private window, to see what new visitors see.
Does Cloudflare cause too many redirects?
Often, in Flexible SSL mode with a server that redirects to https. Cloudflare's own fix is Full or Full (strict) mode with a certificate on the server.
Does a redirect loop hurt search rankings?
A page in a loop cannot be crawled, so search engines cannot see it while the loop lasts. Fix the loop and they can crawl it again.
What does fixing a redirect loop cost?
With us, Server Rescue at $69 for the incident, or $109 for a same-day start. If we cannot fix it, you pay nothing.
/ Sources

Where each statement comes from

Checked against the sources on .

More server help