Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Redirect loop between HTTP and HTTPS: Flexible SSL fix

OPS-065High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

Your origin is the server that hosts your site. A CDN (content delivery network, such as Cloudflare) sits in front of it. With Flexible SSL, the visitor connects to the CDN over HTTPS, but the CDN connects to your origin over plain HTTP.

How the loop forms
  1. VisitorOpens https://example.com
  2. CDN (Flexible)Asks origin over http://
  3. OriginSees HTTP, redirects to https://
  4. Page and formNever loads
  5. Lead or saleNever happens

The visitor never gets past the CDN and origin arguing about the protocol.

Why it costs you leads or sales

Landing page visits that reach the formExample numbers
Landing page visits that reach the form (example)Before loop: 1,000 visits; During loop: 0 visits03837671,0000Before loopDuring loopvisits

Example: 1,000 paid clicks a day before and after a loop starts. Numbers are illustrative.

How to check if your site has it

Confirm the loop
  1. Open the page in a private window

    Visit your HTTPS address. A loop shows a browser error about too many redirects. Clearing cookies can matter, as some loops come from cookies, so test in a fresh private window.

  2. Trace the redirects with curl

    Run the command below. If the same Location header repeats until curl stops, you have a loop.

  3. Check the CDN SSL modeCloudflare

    In Cloudflare, open SSL/TLS > Overview. If it says Flexible and your origin forces HTTPS, that is the cause.

  4. Test the origin directly

    If you can reach the origin by its IP or a non-proxied hostname, check whether it redirects HTTP to HTTPS. If it does, Flexible mode will loop.

Follow redirects and show each hopbash
curl -sIL --max-redirs 10 https://example.com/ | grep -iE '^(HTTP|location)'

How to fix it

Fix the loop
  1. Install a certificate on the origin

    Use your host's free SSL option, Let's Encrypt, or a CDN-issued origin certificate. Check that it covers your domain and www.

  2. Change the CDN SSL modeCloudflare

    In Cloudflare, go to SSL/TLS > Overview and choose Full (strict). Use Full only if the origin has a self-signed certificate you cannot replace yet.

  3. Remove duplicate redirect rules

    Keep one place that forces HTTPS: the CDN (Always Use HTTPS) or the origin, not conflicting rules in several places.

  4. Purge the CDN cache

    Cached redirect responses can keep the loop alive. Purge everything after the change.

If you cannot change the CDN mode: fix it on your platform
  1. Check the URLs

    Go to Settings > General and make sure WordPress Address and Site Address both start with https://.

  2. Trust the forwarded header

    Add the snippet below to wp-config.php above the line 'That's all, stop editing'. It tells WordPress the visitor used HTTPS when the CDN says so.

  3. Review SSL plugins

    If a plugin such as an SSL or redirect plugin forces HTTPS, check its setting for 'detect HTTPS via header' or turn off its redirect and let the CDN handle it.

wp-config.php: trust the CDN's forwarded protocolphp
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
    $_SERVER['HTTPS'] = 'on';
}
nginx: redirect only when the visitor used HTTPnginx
if ($http_x_forwarded_proto = "http") {
    return 301 https://$host$request_uri;
}

How to confirm it's fixed

Fix verification
  • curl -sIL shows a single 301 from http:// to https:// and then a 200
  • Both example.com and www.example.com load without errors
  • A private browser window loads the landing page and the form
  • Submitting a test form works and the thank-you page loads
  • The CDN SSL mode shows Full (strict)
  • Cache purged and checked from a different network or device

How to prevent it happening again

Prevention
  • Use Full (strict) as the default SSL mode on every site behind a CDN
  • Force HTTPS in one place only
  • Re-test key pages after changing SSL plugins, hosts, DNS or CDN settings
  • Renew origin certificates on time, because an expired one can push people back to Flexible
  • Note the SSL mode in your site handover documents

How FunnelGuard handles this

Questions people ask

Why does my site say "too many redirects" after I turned on HTTPS?

Most often your CDN is on Flexible SSL while your server or a plugin forces HTTPS. The CDN reaches your server over HTTP, the server redirects to HTTPS, and this repeats. Switch the CDN to Full (strict) with a valid origin certificate.

How do I fix ERR_TOO_MANY_REDIRECTS on Cloudflare?

Go to SSL/TLS > Overview and change Flexible to Full (strict), after installing a valid certificate on your origin. Then remove duplicate HTTPS redirects and purge the cache. Test with a private window and curl.

What is the difference between Flexible, Full and Full (strict) SSL?

Flexible encrypts only visitor-to-CDN traffic. Full encrypts both legs but accepts any origin certificate, even self-signed. Full (strict) also requires a valid, trusted certificate on the origin, and is the safest choice.

Can a redirect loop hurt my Google Ads or SEO?

Yes. Ad clicks land on an error page, so you pay for visits that cannot convert. Search crawlers also cannot read looping pages, which can hurt indexing if it lasts.

Why does the loop only happen on some pages or for some visitors?

Different rules can apply to different URLs, such as a plugin redirecting only the checkout or a cached redirect on one path. Cookies can also cause loops for logged-in users. Test several URLs in a private window and trace each with curl.

How do I fix a WordPress redirect loop behind a CDN?

Set both WordPress URLs to https:// under Settings > General, and add code to wp-config.php that sets $_SERVER['HTTPS'] to on when X-Forwarded-Proto is https. The better fix is Full (strict) at the CDN.

How can I be alerted if a redirect loop starts?

A synthetic monitor that loads your key pages on a schedule will see the loop. FunnelGuard's redirects check detects loops and sends one alert after a second-region re-check.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: redirects detects loops.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.