TR EN

Fix ERR_TOO_MANY_REDIRECTS (Redirect Loop 310) in WordPress & Cloudflare

The ERR_TOO_MANY_REDIRECTS error occurs when a client is trapped in an infinite HTTP 301/302 redirect loop between client, CDN (Cloudflare), and origin web server.

Root Causes & Failure Triggers

The ERR_TOO_MANY_REDIRECTS error occurs when a client is trapped in an infinite HTTP 301/302 redirect loop between client, CDN (Cloudflare), and origin web server.

  • Cloudflare SSL mode set to 'Flexible' while origin server enforces strict HTTPS redirection.
  • Protocol mismatch between WordPress Site Address (URL) and Home URL in the wp_options database table.
  • Conflicting rewrite rules in .htaccess or Nginx virtual host configurations.
  • Redundant third-party SSL redirect plugins clashing with web server level 301 redirects.

Step-by-Step Fixes

1. Switch Cloudflare SSL Mode to 'Full' or 'Full (Strict)'

Navigate to Cloudflare Dashboard > SSL/TLS > Overview. Change SSL encryption mode from 'Flexible' to 'Full'. This stops Cloudflare from communicating over unencrypted port 80 to an HTTPS-enforcing origin.

2. Hardcode Canonical URLs in wp-config.php

Define canonical URL constants in wp-config.php to override database redirect conflicts:

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

3. Forward HTTPS Proxy Protocol Headers

Add proxy detection logic at the beginning of wp-config.php:

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

4. Restore Clean Default .htaccess Configuration

Replace bloated redirect rules with standard Apache rewrite directives.
💡 Live Diagnostics: Verify your server's SSL chain, DNS records, and HTTP headers using our SSL Checker, Security Headers, or Open Port Scanner tools.

Related Error Troubleshooting Guides

How to Fix Laravel 419 Page Expired (CSRF Token Mismatch)Fix Nginx 502 Bad Gateway Error with PHP-FPM / UpstreamHow to Fix CORS Error: No 'Access-Control-Allow-Origin' HeaderHow to Fix WordPress 500 Internal Server Error (.htaccess & Memory)How to Fix ERR_SSL_PROTOCOL_ERROR in Chrome & BrowsersHow to Fix Nginx 504 Gateway Timeout Error (proxy_read_timeout)Fix WordPress 'Error Establishing a Database Connection' ErrorHow to Fix SSH Connection Refused (Port 22) on Ubuntu/Linux

Frequently Asked Questions

Why does Cloudflare Flexible SSL cause an infinite loop?
In Flexible mode, Cloudflare contacts your origin server over plain HTTP port 80. If your web server enforces HTTPS, it issues a 301 back to Cloudflare, creating an infinite redirect ping-pong.
Do browsers cache 301 redirects?
Yes. Browsers aggressively cache HTTP 301 redirects. Always test in an Incognito / Private browsing window after updating server configs.