In short
A redirect loop is a URL that ends up redirecting to itself, directly or via other URLs: A → B → A. The browser gives up with “This page isn't working” and the ERR_TOO_MANY_REDIRECTS code (Chrome) or “The page isn't redirecting properly” (Firefox). This check consists of finding the two rules that contradict each other and keeping only one. Once it is done, every URL variant on the site ends in a 200.
Why it matters
A page caught in a loop is inaccessible to everyone: visitors, Googlebot, Bingbot and AI assistant crawlers. Google lists “Redirect loop” among the errors behind the “Redirect error” reason in Search Console: the page is not indexed and eventually drops out of the index if it was in it.
The danger is that the loop is often partial. It affects only the HTTP version, only logged-out visitors, only crawlers, or only requests that go through the CDN. The site owner, logged in and served from their cache, sees nothing.
Almost all loops come from two layers that do not see the same request:
- A proxy or a CDN that contacts the server over HTTP: the server thinks the request is insecure and redirects to HTTPS, the proxy sends the request again over HTTP, and so on. This is the most common cause.
- Two opposing rules: the server adds
www, the CMS removes it; the server adds the trailing slash, the application strips it. - A condition that includes its own target: a protected page redirects to
/connexion, which is itself protected.
What it improves
- Accessibility The page can be viewed again, an immediate effect.
- Indexing Google can crawl and index the page again.
- Generative engines Assistants' search crawlers retrieve the page and can cite it.
- Server load Each visit caught in a loop generates up to twenty or so pointless requests.
How to check
Follow the redirects with a limit, without cookies, like a crawler:
curl -sIL --max-redirs 10 https://www.example.com/page/ | grep -i -E "^(HTTP|location)"
A loop shows up as the same location lines coming back, and curl ends with Maximum (10) redirects followed. Test the four origin variants (http:// and https://, with and without www) and the page with and without a trailing slash: the loop often affects only one of them.
To find out which layer is responding, compare with a direct test on the origin server, bypassing the CDN:
curl -sI --resolve www.example.com:443:ORIGIN_IP_ADDRESS https://www.example.com/page/ | grep -i -E "^(HTTP|location|server|cf-ray|x-cache)"
If the origin returns 200 and the loop only exists through the CDN, the problem lies between the two. The server, cf-ray or x-cache headers show who issued each redirect. In the browser, open a private window (no cookies and no 301 cache) and the Network tab of the developer tools, with the “Preserve log” option ticked.
In Search Console, the “Redirect error” reason in the Page indexing report lists the affected URLs.
How to implement
Before you start
Identify the loop's pattern in the curl output, then go to the matching row:
| What curl shows | Likely cause | Section |
|---|---|---|
https:// → https:// (same URL) behind a CDN |
The CDN contacts the origin over HTTP | Cloudflare, AWS |
http:// ↔ https:// |
One layer forces HTTPS, another forces HTTP | Cloudflare, Apache, Nginx |
example.com ↔ www.example.com |
Server and CMS do not choose the same host | Plesk, cPanel, WordPress |
/page ↔ /page/ |
Two opposing trailing-slash rules | Nginx, Next.js |
/compte → /connexion → /connexion |
The login page is itself protected | Laravel, Next.js |
After the fix, purge every cache (CDN, caching plugin, server page cache): a looping redirect may have been stored there. Affected visitors will sometimes have to clear their browser cache, which remembers 301s.
Cloudflare
Versions Cloudflare dashboard, all plans, November 2026.
Cloudflare documents five causes of loops. Check them in this order:
- “Flexible” encryption mode in
SSL/TLS > Overview: Cloudflare contacts the origin over HTTP, the origin redirects to HTTPS, and the loop begins. Install a certificate on the origin (Let's Encrypt or a Cloudflare origin certificate) and switch to “Full (strict)”. In “Automatic” mode (Automatic SSL/TLS), the page shows the mode actually applied: check that it has not stayed on “Flexible”, or choose a custom mode. - “Full” or “Full (strict)” mode with an origin that redirects HTTPS to HTTP: remove that redirect at the origin.
- “Always Use HTTPS” enabled in
SSL/TLS > Edge Certificateswhile the origin redirects to HTTP: same fix. - HSTS enabled with an origin that redirects to HTTP, or with encryption turned off.
- Contradictory rules: a Redirect Rule or an old Page Rule sends to a host that sends back to the first one. Review them from the Rules overview.
Then purge the cache in Caching > Configuration.
Apache
Versions Apache 2.4.
Behind a proxy, a CDN or a load balancer that terminates HTTPS, %{HTTPS} is always off: a rule that tests this variable loops. Test the header passed on by the proxy instead:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301]
Only trust this header if the server can be reached solely through the proxy. Also look for contradictory www rules in the .htaccess file and in the virtual host:
grep -rn -E "R=30|Redirect" /etc/apache2/sites-enabled/ /var/www/example/.htaccess
Reload with sudo apachectl configtest && sudo systemctl reload apache2.
Nginx
Versions Nginx 1.18 and later.
Behind a proxy, the same logic applies with the header variable:
if ($http_x_forwarded_proto != "https") {
return 301 https://www.example.com$request_uri;
}
If Nginx is itself the proxy in front of the application, pass on the original scheme, otherwise the application thinks it is receiving HTTP:
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
For the trailing slash, a rewrite that strips the slash combined with a try_files … $uri/ that adds it back on a real directory produces a loop: choose a single convention. Reload with sudo nginx -t && sudo systemctl reload nginx.
IIS
Versions IIS 10 with the URL Rewrite module 2.1.
In web.config, an HTTPS redirect rule that tests {HTTPS} loops behind a load balancer: test {HTTP_X_FORWARDED_PROTO} with pattern="^https$" negate="true". Failed Request Tracing shows which rule applies on each pass.
AWS
Versions AWS console (CloudFront, Application Load Balancer, Amazon S3), November 2026.
- CloudFront: if the origin protocol policy is “HTTP only” and the origin redirects to HTTPS, a loop is guaranteed. Switch it to “HTTPS only”, or do the HTTPS redirect in CloudFront (“Redirect HTTP to HTTPS”) and remove it from the origin.
- Application Load Balancer: the ALB forwards to the instances over HTTP with the
X-Forwarded-Protoheader. Do the HTTP-to-HTTPS redirect on the ALB's port 80 listener, not on the instances, or have the server test that header. - S3 + CloudFront: a bucket redirection rule that points to the domain name served by the same distribution loops; serve redirects from a CloudFront Function instead.
Plesk
Versions Plesk Obsidian 18.0.
In the domain's hosting settings, the “Preferred domain” (with or without www) must match the address configured in the CMS. If the “Permanent SEO-safe 301 redirect from HTTP to HTTPS” option is ticked, remove every HTTPS rule from the .htaccess file and from the “Additional nginx directives”. Plesk puts Nginx in front of Apache: Apache then receives the request over HTTP, and a .htaccess rule that tests %{HTTPS} can loop.
cPanel
Versions cPanel & WHM 110 and later, Jupiter theme.
Compare three settings: the “Force HTTPS Redirect” option in Domains > Domains, the rules in Domains > Redirects (in particular the “Redirect with or without www.” choice) and the rules written in public_html/.htaccess. A redirect to www in the Redirects screen and an address without www in the CMS loop. Keep a single source of truth.
Shared hosting
The usual causes: a “force HTTPS” checkbox in the panel combined with a .htaccess rule that tests the scheme incorrectly, or Cloudflare in Flexible mode in front of the hosting. Temporarily rename the .htaccess file (to .htaccess.bak) to see whether the loop disappears, then bring its rules back one by one.
WordPress
Versions WordPress 6.4 to 7.1.
- Site addresses: in
Settings > General, “WordPress Address (URL)” and “Site Address (URL)” must contain exactly the final URL, scheme andwwwincluded. If the admin area is inaccessible, set them inwp-config.php:
define( 'WP_HOME', 'https://www.example.com' );
define( 'WP_SITEURL', 'https://www.example.com' );
- Behind a proxy or a CDN: the WordPress documentation states that HTTPS settings can cause an infinite loop when HTTPS is handled by a reverse proxy. Add before the
/* That's all, stop editing! */line:
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && strpos( $_SERVER['HTTP_X_FORWARDED_PROTO'], 'https' ) !== false ) {
$_SERVER['HTTPS'] = 'on';
}
- Plugins: an HTTPS, redirect or caching plugin can contradict the server. Disable them all by renaming the
wp-content/pluginsfolder over SFTP, test, then reactivate them one by one. - Loop on
/wp-adminonly: delete the domain's cookies; a session cookie issued on the other host (wwwor not) is often the cause.
Shopify
Versions Shopify admin interface, all plans, November 2026.
Shopify handles HTTPS and the primary domain on its own. A loop usually comes from a URL redirect whose target redirects back to the source: check them in Content > Menus, then URL Redirects. It can also come from a misconfigured primary domain in Settings > Domains.
Laravel
Versions Laravel 10 to 13. Only the trusted proxy declaration changes from Laravel 11 onwards.
Check that the login route is not placed in a group protected by the auth middleware, and that APP_URL matches the final URL. Behind a proxy, declare it so that request()->isSecure() and the generated URLs reflect HTTPS. Replace '*' with your proxies' addresses if you know them.
Laravel 11 to 13
In bootstrap/app.php:
->withMiddleware(function (Middleware $middleware): void {
$middleware->trustProxies(at: '*');
})
Laravel 10 and earlier
In app/Http/Middleware/TrustProxies.php, set the $proxies property:
protected $proxies = '*';
Next.js
Versions Next.js 15 and 16 (App Router and Pages Router). The proxy file is renamed from Next.js 16 onwards.
- Trailing slash:
trailingSlashinnext.config.jsand an opposite rule at the hosting provider or inredirects()loop. Keep only the Next.js option. - Redirect to the login page: in the proxy (formerly middleware), exclude the target from the redirect condition, with a
matcheror a test on the path.
Next.js 16
The file is called proxy.ts, at the root of the project or in src/, and exports a proxy function:
import { NextResponse, type NextRequest } from 'next/server';
export function proxy(request: NextRequest) {
const estConnecte = request.cookies.has('session');
if (estConnecte) {
return NextResponse.next();
}
if (request.nextUrl.pathname.startsWith('/connexion')) {
return NextResponse.next();
}
return NextResponse.redirect(new URL('/connexion', request.url));
}
export const config = {
matcher: ['/compte/:path*', '/connexion'],
};
The middleware.ts name is still accepted but deprecated: npx @next/codemod@canary middleware-to-proxy . renames the file and the function.
Next.js 15
The file is called middleware.ts and exports a middleware function. The logic is the same:
import { NextResponse, type NextRequest } from 'next/server';
export function middleware(request: NextRequest) {
const estConnecte = request.cookies.has('session');
if (estConnecte) {
return NextResponse.next();
}
if (request.nextUrl.pathname.startsWith('/connexion')) {
return NextResponse.next();
}
return NextResponse.redirect(new URL('/connexion', request.url));
}
export const config = {
matcher: ['/compte/:path*', '/connexion'],
};
Common mistakes
- Clearing only the browser cache: the loop disappears for you, but not for crawlers or other visitors if the cause is on the server side.
- Stacking HTTPS redirects at the CDN, the server and the CMS: a single layer should force HTTPS, preferably the one closest to the visitor.
- Testing only while logged in: loops that affect only anonymous visitors or crawlers go unnoticed.
- Leaving Cloudflare on Flexible “for the time being”: it is the leading cause of loops reported by Cloudflare, and the connection between Cloudflare and the server is not encrypted.
- Not purging after the fix: a CDN or a caching plugin may keep serving the faulty redirect.
- Trusting
X-Forwarded-Protoon an exposed server: anyone can send this header; limit trust to the proxy's addresses.
Frequently asked questions
What does the ERR_TOO_MANY_REDIRECTS error mean?
ERR_TOO_MANY_REDIRECTS means the browser followed too many redirects without reaching a page: a rule sends to a URL that sends back, directly or not, to the first one. The most common cause is a CDN or a proxy that contacts the server over HTTP while the server forces HTTPS, for example Cloudflare's Flexible mode. Next come contradictory www and trailing-slash settings.
How do I fix a redirect loop with Cloudflare?
Open SSL/TLS in the Cloudflare dashboard and check the encryption mode. In Flexible mode, Cloudflare contacts your server over HTTP and the server, which forces HTTPS, redirects endlessly. Install a certificate on the origin server and switch to Full (strict). Then check that no Redirect Rule contradicts the origin's redirects, and purge the cache.
Why does the redirect loop only affect some visitors?
A partial redirect loop depends on what sets requests apart: session cookies, browser cache, whether or not the request goes through the CDN, HTTP or HTTPS version, presence of www. A logged-in visitor or one served from a cache may see nothing, while crawlers and new visitors fall into the loop. Test with curl, without cookies, on every variant of the URL.
Does a redirect loop hurt SEO?
Yes, if it lasts. A page caught in a loop cannot be crawled: Search Console classifies it as a redirect error, it is not indexed and, if it was, it eventually drops out of the index. A loop fixed within a few hours usually has no lasting effect. After the fix, request a recrawl of the important pages with the URL Inspection tool.
Resources
- Cloudflare: ERR_TOO_MANY_REDIRECTSdevelopers.cloudflare.com
- Cloudflare: Encryption modesdevelopers.cloudflare.com
- WordPress: HTTPS and reverse proxiesdeveloper.wordpress.org
- Search Console Help: Redirect errorssupport.google.com
- Laravel: Trusted proxieslaravel.com
- Next.js: Redirecting and Proxynextjs.org
Updated on
Topic checklist (PDF)