Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Wordpress

WordPress: Fix a Redirect Loop After Forcing HTTPS in Settings

- 28.11.26 - ErcanOPAK

📝 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.

— WordPress Admin

Related posts:

WordPress: Recover a Site After Restoring the Wrong Database Backup

WordPress: Recover a Site After Restoring the Wrong Database Backup

WordPress: Understand the Difference Between Actions and Filters

WordPress: Understand the Difference Between Actions and Filters

WordPress Pages Randomly Lose Styles

WordPress Pages Randomly Lose Styles

Views: 6
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

HTML5: Fix a Required Field Skipping Screen Reader Focus
Visual Studio: Fix Code Cleanup on Save Skipping a Format Rule

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 562 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com