What the browser is telling you
A redirect is a response with a 3xx status and a Location header: "what you asked for is over there". Browsers follow it without asking, and they follow the next one too. To avoid running forever they stop after a limit — around twenty hops — and show an error: ERR_TOO_MANY_REDIRECTS in Chrome and Edge, "The page isn't redirecting properly" in Firefox, "Too many redirects occurred" in Safari.
A loop almost never comes from one bad rule. It comes from two rules that each look correct and disagree: one says HTTP must become HTTPS, the other serves the content over HTTP; one says www is the real address, the other says the bare domain is. Each is fine alone; together they send the browser back and forth until it quits. The job is to find both rules and make them agree — usually by deleting one of them.
See the loop with curl
Before changing anything, look at the chain. curl -I asks for headers only and -L follows redirects, so together they print every hop (commands below).
Read the location lines from top to bottom. The same two or three addresses repeat — for example http:// → https:// → http:// — and those addresses tell you which rules are involved. Two more checks narrow it down.
Ask your origin directly, with --resolve so the request still carries your hostname. If the origin alone redirects to the address you asked for, the loop is on the origin side.
Try a private window. If the loop disappears there, the cause is in your browser: an old permanent redirect, a cookie or HSTS (see below). Browsers remember 301s, so a loop you already fixed can keep appearing in the tab where you first met it.
Follow the chain, then ask the origin directly
# every hop through the CDN, headers only
curl -sIL --max-redirs 10 https://www.example.com/ | grep -iE '^(HTTP|location)'
# the same address straight to the origin, over both schemes
curl -sI --resolve www.example.com:443:ORIGIN_IP https://www.example.com/ | grep -iE '^(HTTP|location)'
curl -sI --resolve www.example.com:80:ORIGIN_IP http://www.example.com/ | grep -iE '^(HTTP|location)'
Cause 1 — the origin redirects to HTTPS but receives HTTP
This is the most common loop behind any CDN or SSL proxy. The visitor connects to the edge over HTTPS. The edge then connects to your origin — and if it does so over plain HTTP, your origin sees an HTTP request. Its rule says "HTTP? Redirect to HTTPS." The visitor follows to the HTTPS address, which is where they already were, the edge fetches over HTTP again, and the loop is complete.
Your origin cannot tell from its own connection what the visitor used. That is what X-Forwarded-Proto is for: the edge writes the visitor's original scheme into it on every request. A redirect rule that checks X-Forwarded-Proto instead of the connection redirects only the visitors who really arrived over HTTP.
On cdn.com.tr the edge reaches your origin with the protocol the visitor used: HTTP visitors on your origin's HTTP port, HTTPS visitors on its HTTPS port. The loop appears when Origin HTTPS Port and Origin HTTP Port on the origin page are the same — both 80, for example — because HTTPS visitors are then fetched over plain HTTP. Enter the origin's real HTTPS port (usually 443) if it serves HTTPS, make its redirect read X-Forwarded-Proto, or remove the origin's redirect and let the edge do it.
nginx on the origin: redirect only visitors who really used HTTP
# the scheme the visitor used at the edge, or this connection's if the header is absent
map $http_x_forwarded_proto $visitor_scheme {
default $http_x_forwarded_proto;
'' $scheme;
}
server {
listen 80;
server_name www.example.com;
if ($visitor_scheme = http) {
return 301 https://$host$request_uri;
}
# ... the rest of the site
}
Cause 2 — two places redirect, and one points backwards
Redirecting HTTP to HTTPS in two places is harmless as long as both point the same way. The loop appears when one of them points backwards: a rule sends HTTPS visitors to an http:// address, or an old .htaccess line forces HTTP for part of the site while another rule forces HTTPS.
Pick one place for the HTTP → HTTPS redirect. The edge is the natural one: the redirect is answered right there, without a trip to your origin, and it works the same whatever your origin runs. On cdn.com.tr, add a domain redirect for the domain with only HTTP ticked under For requests over, choose https:// under To and enter the same domain. HTTP requests then get a 301 to the HTTPS address with the same path and query string, and HTTPS requests are served by your rules as before. Then remove or relax the origin's own scheme redirect so the two can never disagree.
Never send HTTPS requests to an http:// target while your origin or an HSTS policy pushes visitors to HTTPS. That is a loop by construction.
Cause 3 — www and the bare domain disagree
The same pattern with hostnames: one rule says example.com → www.example.com, another says www.example.com → example.com. It happens when a CMS setting, a web server rule and a CDN redirect were each set up at different times by different people.
Choose the canonical hostname once and redirect only the other one to it. In the cdn.com.tr domain redirect editor, domains are matched exactly as written: to settle on www.example.com, tick only example.com in the redirect. Then check that your application's own idea of its address — the next section — names the same hostname.
Cause 4 — WordPress and other CMSs that know their own address
WordPress stores its address in two settings, WordPress Address (URL) and Site Address (URL) (siteurl and home in the database), and redirects requests that do not match them. If they say https://www.example.com while requests reach WordPress looking like http:// — because the proxy in front connects over HTTP — WordPress redirects to HTTPS, the proxy fetches over HTTP again, and you have Cause 1 inside your CMS.
WordPress decides whether a request is HTTPS from the server's own connection. Behind a proxy that connects over HTTP, tell it to trust the forwarded scheme by adding the lines below near the top of wp-config.php, above the line that says to stop editing.
Then make sure both address settings use the same scheme and hostname as your canonical address. If the loop locks you out of the admin area, set them in wp-config.php with WP_HOME and WP_SITEURL. Other applications follow the same idea under other names — a base URL setting and a list of trusted proxies; the X-Forwarded-For guide shows the Laravel side.
wp-config.php
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = 'on';
}
// only if the admin area is unreachable:
define('WP_HOME', 'https://www.example.com');
define('WP_SITEURL', 'https://www.example.com');
Cause 5 — cookies, HSTS and remembered redirects
Some loops live in the browser rather than on the server, which is why one person sees them and another does not.
Cookies. A login or language check that redirects "if the cookie is missing" loops forever when the cookie can never be set: it is marked Secure while the page is served over HTTP, its Domain does not match the hostname, or it is too large. Clearing the site's cookies is the quick test; fixing the cookie's attributes is the real fix.
HSTS. Once a browser has seen an HSTS header, it rewrites every http:// address for that domain to https:// before sending anything. If a rule then redirects to http://, the browser turns it straight back into HTTPS — an instant loop that only browsers holding the HSTS entry experience. With HSTS on, every redirect must point at HTTPS.
Remembered 301s. A 301 redirect is permanent and browsers keep it. After fixing a loop, test with curl or a private window rather than the tab where you met it. If your delivery rule caches redirect responses, purge the affected addresses as well so the edge stops serving the old answer.
A setup that does not loop
Most loops disappear when each job has exactly one owner.
HTTP → HTTPS: at the edge, with an HTTP-only domain redirect to https:// on the same domain.
www and the bare domain: at the edge too, redirecting only the hostname that is not canonical.
The origin: serves content and does not redirect between schemes or hostnames. If it must, it reads X-Forwarded-Proto and X-Forwarded-Host, which the edge sends on every request.
The application: its base URL matches the canonical address exactly.
HSTS: switched on last, once every path works over HTTPS without a redirect back.
Set up this way, a rule added later has only one place where it can conflict, and curl -sIL shows a chain of one or two hops at most.
How to set it up
Step-by-step guides in the help centre:
ERR_TOO_MANY_REDIRECTS FAQ
Why did ERR_TOO_MANY_REDIRECTS start after I put my site behind a CDN?
Because the CDN changes how your origin sees requests. Before, visitors reached your server over HTTPS directly; now the edge connects to it, and if that connection is plain HTTP, your server's HTTP-to-HTTPS rule fires on every request. Let the origin read X-Forwarded-Proto, give the edge your origin's HTTPS port, or move the redirect to the edge.
Will clearing cookies fix it?
Only when a cookie is the cause. It is a good quick test: if the error stops after clearing the site's cookies or in a private window, look at the cookie and at remembered redirects. If it continues everywhere, the loop is on the server side and curl -sIL will show it.
How do I see which rules are looping?
Run curl -sIL https://your-domain/ | grep -iE '^(HTTP|location)'. It prints the status and target of each hop; the addresses that repeat tell you which rules are involved.
My WordPress admin is stuck in a redirect loop. What should I check?
That WordPress Address and Site Address use the same scheme and hostname as the address you visit, and that WordPress recognises HTTPS behind the proxy ($_SERVER['HTTPS'] set from X-Forwarded-Proto in wp-config.php). A security or caching plugin that forces HTTPS or a hostname is the next suspect.
Does the CDN tell my origin which scheme the visitor used?
Yes. On cdn.com.tr the edge sends X-Forwarded-Proto (http or https, as the visitor used), X-Forwarded-Host and X-Forwarded-Port on every request to your origin.
Can the edge redirect HTTP to HTTPS for me?
Yes. Add a domain redirect with only HTTP ticked, https:// as the target protocol and the same domain. HTTP requests get a 301 to HTTPS with the path and query string kept; HTTPS requests are served by your rules as before.