← All posts

ERR_TOO_MANY_REDIRECTS: breaking a WordPress redirect loop

“This page isn't working, redirected you too many times”: a loop between HTTP and HTTPS or www and non-www. How to spot it and break it.

ERR_TOO_MANY_REDIRECTS: breaking a WordPress redirect loop

Key points

  • Two rules bounce visitors back and forth: HTTP/HTTPS or www/non-www.
  • A CDN or proxy in “Flexible” mode is a common cause.
  • curl -I shows every step of the loop.

The browser gives up after twenty-odd redirects. The site is not deeply broken: two rules contradict each other, each sending the visitor to the other.

See the loop

This command prints every redirect and its target:

curl -sIL https://www.mysite.com | grep -i -E '^(HTTP|location)'

If you see http:// and https:// alternating, or www and non-www, you have the cause. Also clear the site’s cookies, which can keep the loop going.

Cause 1: a proxy in Flexible mode

With Cloudflare SSL set to “Flexible”, visitors arrive over HTTPS but Cloudflare talks to your server over HTTP. WordPress, set to HTTPS, redirects to HTTPS… and the loop starts. Switch SSL to “Full (strict)” with a certificate on the server. If you cannot, tell WordPress the original request was secure:

if (($_SERVER['HTTP_X_FORWARDED_PROTO'] ?? '') === 'https') {
    $_SERVER['HTTPS'] = 'on';
}

Cause 2: conflicting addresses

WordPress’s site address is https://mysite.com but .htaccess or the host forces www. Pick one version and align both settings. If the admin is unreachable, force the values in wp-config.php:

define('WP_HOME', 'https://www.mysite.com');
define('WP_SITEURL', 'https://www.mysite.com');

Cause 3: duplicate rules

One HTTPS redirect in .htaccess, another in the hosting panel, a third in a plugin: common after several successive providers. Keep exactly one, ideally at server level.

FAQ

The loop only affects the admin

Often FORCE_SSL_ADMIN behind an HTTP proxy: the X-Forwarded-Proto fix above solves it.

It works on my phone but not my computer

Clear the browser cache and cookies: an old 301 redirect is remembered.

Facing this on your site or app? We diagnose and fix it.

Share LinkedIn Facebook X WhatsApp
</>

webtestudio

Web agency: custom WordPress sites, premium themes and SaaS software.

Discuss your project →