📝 Fix a Redirect Loop After Forcing HTTPS in Settings
Setting the Site Address and WordPress Address to https:// in Settings > General while the site actually sits behind a reverse proxy or load balancer that terminates SSL puts WordPress itself in the dark about the original request scheme – the proxy forwards the request to WordPress over plain HTTP internally, so is_ssl() evaluates $_SERVER[‘HTTPS’], which the proxy never sets, and WordPress concludes every single request is unencrypted. With the site URLs forced to https://, WordPress’s own canonical-redirect logic then issues a 301 to the https version on every request it believes is plain HTTP – and since the browser is already on https://, that redirect lands back on the exact same page, producing an infinite loop entirely inside WordPress’s own logic.
🔎 The Problem
// wp-config.php - missing proxy awareness // (nothing here checks X-Forwarded-Proto at all) // Request from browser: https://example.com/ // Load balancer -> WordPress over plain HTTP internally // is_ssl() evaluates $_SERVER['HTTPS'], which the LB never sets, // so WordPress believes every request is plain HTTP // Settings > General has Site/WordPress Address forced to https:// // -> WordPress issues a 301 to the https:// URL on every request // -> browser already on https:// -> redirect loop, ERR_TOO_MANY_REDIRECTS
✅ Fix: Teach WordPress About the Proxy
- Add the standard proxy-awareness snippet near the top of wp-config.php: if (($_SERVER[‘HTTP_X_FORWARDED_PROTO’] ?? ”) === ‘https’) { $_SERVER[‘HTTPS’] = ‘on’; } so is_ssl() reports correctly for requests the load balancer already terminated as HTTPS.
- Confirm the load balancer or reverse proxy is actually sending X-Forwarded-Proto (or X-Forwarded-Ssl) on every request – a proxy that forwards plain HTTP internally without setting either header leaves WordPress no way to know the original scheme was HTTPS.
- Clear any object cache and page cache the loop may have poisoned with a cached 301 after the wp-config.php change, since a caching layer can keep replaying the old redirect even after WordPress itself stops issuing it.
🚨 Why This Is Dangerous
A redirect loop triggered this way looks identical in the browser to a dozen unrelated misconfigurations, so it’s easy to burn an hour chasing .htaccess rules or a caching plugin before realizing the real gap is a single missing header check in wp-config.php.
To WordPress, ‘secure’ isn’t about what the browser sees – it’s about what $_SERVER[‘HTTPS’] says, and behind a proxy nobody sets that for you by default.




