Skip to content

ERR_TOO_MANY_REDIRECTS on a cPanel site: breaking the redirect loop

The browser stops with "redirected you too many times". An HTTP-to-HTTPS or www loop is sending the request in circles. Here is how to find the loop and break it.

ERR_TOO_MANY_REDIRECTS — “example.com redirected you too many times” — means the browser followed redirect after redirect until it gave up. Some layer keeps sending the request somewhere that sends it right back: an .htaccess rule forcing HTTPS while a proxy already terminated SSL, a www/non-www pair pointing at each other, or an application redirect fighting a server redirect. Unlike a server-side 508 Loop Detected (Apache catching its own internal loop), this is a chain of full HTTP 301/302 responses the browser is bouncing between. The fix is to find the two endpoints of the loop and make them agree on a single destination.

What’s happening

A redirect loop is any cycle of HTTP 3xx responses with no fixed point: A redirects to B, B redirects back to A (directly or through C). The browser follows up to ~20 hops, then stops. On cPanel the recurring patterns are:

  • HTTPS redirect behind a terminating proxy. Cloudflare (in Flexible SSL mode) or an Nginx/load-balancer front-end speaks HTTPS to the visitor but plain HTTP to the cPanel origin. An .htaccess rule that forces HTTPS sees the origin request as http, redirects to https, the proxy re-sends it as http to the origin, and the loop is sealed.
  • www vs non-www both redirecting. One rule sends example.com → www.example.com and another (or a plugin) sends www.example.com → example.com. Each canonicalizes to the other.
  • Application + server both redirecting. WordPress siteurl/home forces one host/scheme while .htaccess, a vhost, or Cloudflare forces a different one.
  • Trailing-slash rules that add and remove a slash in turn.

The signature is a never-resolving page; the cause is always two redirect sources disagreeing.

How to verify

Trace the redirect chain — curl shows every hop and exposes the cycle immediately.

# Follow and print each redirect hop
curl -sIL http://example.com/ | grep -iE 'HTTP/|Location'
curl -sIL https://example.com/ | grep -iE 'HTTP/|Location'

# Same, the explicit www and non-www forms
curl -sI https://www.example.com/ | grep -iE 'HTTP/|Location'

Look at every place a redirect could originate: .htaccess, the app’s stored URL, and whether a proxy is in front.

# Redirect/rewrite rules in the account's .htaccess
grep -niE 'rewrite|redirect|https' /home/<cpaneluser>/public_html/.htaccess

# WordPress canonical host/scheme
mysql <dbname> -e "SELECT option_name,option_value FROM wp_options WHERE option_name IN ('siteurl','home');"

# Is the request arriving via a proxy (Cloudflare / front-end)?
curl -sI https://example.com/ | grep -iE 'server|cf-ray|x-forwarded'
tail -20 /home/<cpaneluser>/logs/<domain>.error.log

If a proxy is terminating SSL, confirm what scheme the origin actually sees:

# The access log / a phpinfo will show HTTPS off at the origin behind Flexible SSL
grep -i 'HTTPS' /home/<cpaneluser>/public_html/.htaccess

The fix

  1. HTTPS loop behind a terminating proxy — the most common case with Cloudflare. The origin sees http, so a “force HTTPS” rule loops forever. Either switch the proxy to Full (or Full Strict) SSL so it speaks HTTPS to the origin (cPanel + AutoSSL gives you a valid origin cert), or change the .htaccess rule to honour the forwarded scheme: redirect only when %{HTTP:X-Forwarded-Proto} is http, not when %{HTTPS} is off. Do not run Cloudflare Flexible and a server-side force-HTTPS rule together.
  2. www and non-www both redirecting — curl shows example.com → www → example.com. Pick one canonical host and make every layer agree. Keep a single redirect (e.g. non-www → www) in .htaccess, remove the opposing rule, and set the app’s stored URL to the same host. Two canonicalization rules pointing at each other is the textbook loop.
  3. App URL fighting the server — WordPress siteurl/home forces https://www while .htaccess forces http:// (or bare). Align them: set both wp_options values and the .htaccess rule to the same scheme and host. After editing the database URL, clear any cache so the corrected redirect is served.
  4. Trailing-slash rules colliding — one rule adds a slash, another strips it. Keep a single, consistent trailing-slash policy in .htaccess (or let the framework handle it) and remove the competing rule.
  5. Cloudflare page rule or redirect — a “Always Use HTTPS” page rule plus a server redirect can double up. Audit Cloudflare’s SSL/TLS mode and page rules alongside the origin rules; fix the duplication in one place, not both.
  6. Isolate by disabling .htaccess — rename .htaccess (mv .htaccess .htaccess.bak) and re-test with curl -IL. If the loop clears, the cause is in the file; re-add rules one at a time until it returns. If the loop persists with .htaccess gone, the redirect is coming from the app or the proxy, not Apache.
  7. Clear browser and edge cache before declaring victory — browsers cache 301s aggressively, so a fixed loop can appear to persist. Test with curl (which ignores browser cache) and purge the CDN; a clean curl -IL ending in a single 200 is the real proof.

Once curl -sIL shows the request reaching a single 200 with no repeating Location, the loop is broken — that terminating 200 after at most one redirect is what confirms it, not a browser that may still be serving a cached 301. Stack Harbor handles cPanel redirect-loop and proxy-SSL triage under cPanel/WHM management — start a conversation.