Redirect chains and loops: fixing http-to-https and www redirects
How redirects work, why chains slow your site and loops break it, and how to send every version of your address to one final address in a single step.
Published
On this page
The short answer: pick one final address for your site, such as https://www.example.com/, and send every other version straight to it with a single permanent redirect (301 or 308). A chain happens when a visitor is passed through several redirects before arriving. A loop happens when two rules keep sending each other back and forth, so the page never loads. Both are usually caused by two separate systems, such as your hosting panel and your site's own settings, each adding a redirect rule.
Redirects are meant to be invisible. When they go wrong, pages load slowly, search engines waste effort, and in the worst case visitors see "too many redirects" instead of your site. This guide explains how redirects work, how to spot chains and loops, and how to fix the common http-to-https and www mix-ups.
How redirects work
When a browser asks for a page, the server can reply with a status code in the 300s and a Location header giving a new address. The browser then asks for that address instead. Each of these steps is called a hop.
The code tells the browser, and search engines, whether the move is permanent or temporary. MDN's guide to redirections sets out the differences:
| Code | Type | When to use it |
|---|---|---|
| 301 Moved Permanently | Permanent | The usual choice for moving a page or a whole site. Browsers may change a form submission to a normal page request. |
| 308 Permanent Redirect | Permanent | Like 301, but the browser must repeat the request exactly, including form data. |
| 302 Found | Temporary | A short-term move, such as a maintenance page. |
| 303 See Other | Temporary | Sending a visitor to a results page after they submit a form. |
| 307 Temporary Redirect | Temporary | Like 302, but the request must be repeated exactly. |
For moving to HTTPS or choosing between www and no www, the move is permanent, so use 301 or 308. Google's guidance on redirects says permanent redirects are a strong signal that the new address is the one to show in search results, while temporary ones suggest the old address should stay.
Why chains matter
A chain is any route with more than one hop. A typical example: a visitor types http://example.com, gets sent to https://example.com, then to https://www.example.com, then to https://www.example.com/home.

Each hop adds a round trip before anything appears on screen, which is especially noticeable on mobile connections. Search engines also have limits. Google's documentation on HTTP errors says its crawlers follow up to 10 redirect hops by default; beyond that, the page is treated as an error. Long chains rarely reach that, but each extra hop is wasted work and another place for a mistake.
Try it now
Redirect Checker
Follow a URL's redirect chain hop by hop: status codes, destinations, timing, HTTPS downgrades, loops and where it finally ends up.
Why loops happen
A loop is a chain that never ends: address A sends you to B, and B sends you back to A. Browsers give up after a number of attempts and show an error such as "This page isn't working: redirected you too many times". The causes are nearly always one of these.
Two systems disagree about www
Your hosting panel is set to add www, while your website's own settings (for example the site address in WordPress) are set without it. Each one "corrects" the other, forever. The fix is to make both agree, then remove the duplicate rule.
HTTPS behind a proxy or CDN
This is the classic loop. A CDN such as Cloudflare accepts the visitor's HTTPS connection but talks to your server over plain HTTP. Your server sees an HTTP request and redirects to HTTPS. The CDN passes that redirect back to the visitor, who asks again over HTTPS, and the CDN asks your server over HTTP again. The fix is either to make the CDN connect to your server over HTTPS or to make your server trust the CDN's X-Forwarded-Proto header. Cloudflare's guide to redirect loops explains this for its Flexible setting and recommends Full or Full (strict) instead.
Old rules left behind
Redirect rules can live in several places: .htaccess, the server configuration, the hosting panel, a CDN page rule, and plugins inside the site. After a few changes, two of them may point in opposite directions. Search all of them before adding a new one.
Checking your redirects
The Redirect Checker follows each hop and shows the status code, the address and the server it connected to. Test every version of your address, not just one:
http://example.comhttp://www.example.comhttps://example.comhttps://www.example.com
Three of these should show exactly one hop to the fourth, and the fourth should show no redirect at all, with an HTTP 200. Also check an inner page, such as http://example.com/contact, to make sure the path is kept rather than everything being sent to the home page.
The checker follows HTTP redirects only, up to 10 hops. If a page uses an HTML meta refresh, we point it out, but we don't follow it, and we don't run JavaScript, so a redirect done in a script won't appear. Google treats an instant meta refresh as a permanent redirect, but recommends server-side redirects wherever you can use them.
To see the raw Location header and other response details for a single address, use the HTTP Header Checker.
Try it now
HTTP Header Checker
See the HTTP status and every response header a website sends, including caching, cookies, server and security headers, for each redirect.
Fixing http-to-https and www in one step
The cleanest approach is one rule that sends anything that isn't already the final address straight there. On Apache hosting, which includes most cPanel hosts, this goes near the top of the .htaccess file in your site's main folder. This example uses www as the final version; replace the domain with your own.
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301]
On nginx, use two small server blocks: one catches every plain-HTTP request, the other catches HTTPS requests for the version without www.
server {
listen 80;
server_name example.com www.example.com;
return 301 https://www.example.com$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
# plus your usual ssl_certificate lines
return 301 https://www.example.com$request_uri;
}
Before adding a rule like this, switch off any other redirect settings that do the same job, such as a "force HTTPS" option in the hosting panel or a plugin. Otherwise you may create the very loop you are trying to avoid. If your site is behind a CDN, set the redirect in one place only, ideally at the CDN.
Once the redirects are clean and HTTPS works everywhere, consider adding HSTS. It tells browsers to use HTTPS for your site automatically, which removes the first http hop for returning visitors.
Common questions
Should I use www or not?
Either is fine. What matters is choosing one and using it consistently in redirects, links, your sitemap and canonical tags. Changing your mind later means another round of redirects.
How long should I keep redirects after moving pages?
As long as you can, and at least a year. Old links in emails, bookmarks and other websites keep working only while the redirect exists.
Is a 302 bad for search engines?
Not bad, just a different message. A 302 says the move is temporary, so search engines may keep showing the old address. For a permanent change, use 301 or 308.
The checker shows a loop, but the site works for me. Why?
Your browser may have cached a working route, or you may be logged in, which some sites handle differently. Check in a private window. Some loops also only affect one version of the address, such as http without www.
Do redirects lose search ranking?
Google treats a permanent server-side redirect as a strong signal that the new address is the one to show in search results. Chains and loops are the real problem, because they slow crawling and can stop a page being reached at all.
Related tools
-
Redirect Checker
Follow a URL's redirect chain hop by hop: status codes, destinations, timing, HTTPS downgrades, loops and where it finally ends up.
-
HTTP Header Checker
See the HTTP status and every response header a website sends, including caching, cookies, server and security headers, for each redirect.
More website guides
-
Website
security.txt explained: how to publish one
What a security.txt file is for, the Contact and Expires fields it needs, where to put it on your website and the mistakes that make researchers ignore it.
-
Website
Robots.txt and sitemaps: what search engines actually read
What robots.txt and sitemaps really do, the rules search engines follow, why neither keeps a page out of results, and the mistakes that cause the most trouble.
-
Website
Why is my SSL certificate not trusted?
The five common reasons browsers reject a certificate, from a missing intermediate to a wrong clock, and how to fix each one.