W
WP Quick Search
Features Integration Pricing Documentation Blog Products Demo
Login Start for free
Login Start for free
Blog / WordPress/ Fixing WordPress Admin Login Redirect Loops: SSL Configuration Issues & Solutions

Fixing WordPress Admin Login Redirect Loops: SSL Configuration Issues & Solutions

2020-11-30 · Ryan · Post Comment
WordPress后台登录重定向次数过多:SSL配置问题与解决方案

After configuring an SSL certificate for a WordPress site, some users may encounter an inability to log into the admin dashboard, with the browser displaying a "Too many redirects" or "ERR_TOO_MANY_REDIRECTS" error. This is typically caused by incorrect SSL/HTTPS enforcement settings, leading to an infinite redirect loop between HTTP and HTTPS for the login page.

Problem Causes

This issue usually occurs under the following circumstances:

  • An SSL certificate is installed and active, but WordPress configuration is not fully updated to enforce HTTPS.
  • Server environment variables (like $_SERVER['HTTPS']) are not correctly set to 'on', preventing WordPress from accurately detecting a secure connection.
  • Website URL settings (WP_SITEURL, WP_HOME) or the siteurl and home options in the database still use HTTP addresses, conflicting with server-side HTTPS enforcement rules.

Solutions

The core solution is to explicitly inform WordPress that SSL is enabled and force the admin area to use HTTPS. Edit the wp-config.php file in your site's root directory via FTP, SFTP, or your hosting control panel's file manager.

Method 1: Modify wp-config.php (Recommended)

Add the following code in wp-config.php, after the <?php tag and before any other code:

// Force SSL/HTTPS to resolve admin login redirect loops
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
    $_SERVER['HTTPS'] = 'on';
}
if (isset($_SERVER['HTTPS'])) {
    $_SERVER['HTTPS'] = $_SERVER['HTTPS'] == 'on' ? 'on' : 'off';
}
if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == 'off') {
    $_SERVER['HTTPS'] = 'on';
}
define('FORCE_SSL_LOGIN', true);
define('FORCE_SSL_ADMIN', true);

Method 2: Hardcode Site URLs (Comprehensive Fix)

If Method 1 doesn't work, you may also need to hardcode the site URLs in wp-config.php. Add these lines after the previous code:

define('WP_HOME', 'https://yourdomain.com');
define('WP_SITEURL', 'https://yourdomain.com');

Note: Replace 'yourdomain.com' with your actual domain.

Next Steps & Verification

  1. Save the file and upload it back to the server.
  2. Clear your browser cache and cookies, then restart the browser.
  3. Attempt to log in using https://yourdomain.com/wp-admin.
  4. Update database URLs (Optional): After successful login, go to Settings → General and verify both "WordPress Address (URL)" and "Site Address (URL)" start with HTTPS. If they still show HTTP, update them manually.

Prevention & Best Practices

  • Before installing an SSL certificate, consider pre-configuring the SSL enforcement code in wp-config.php.
  • Use a reliable SSL certificate and ensure your server (e.g., Nginx/Apache) SSL configuration is correct.
  • Plugins like "Really Simple SSL" can assist with migration, but manual configuration of wp-config.php provides a more permanent solution.

Following these steps should resolve most WordPress admin login redirect loops caused by SSL configuration. If the issue persists, check server rewrite rules (.htaccess or Nginx config) or contact your hosting provider to confirm SSL is properly installed and active.

Admin LoginhttpsRedirect LoopssltroubleshootingWordPresswp-config.php
Previous
Complete Guide to Adding Custom Meta Boxes in WordPress
Next
How to Get a List of Posts by a Specific User ID in WordPress

Post a Comment Cancel reply

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

Quick Navigation
W
WP Quick Search
About Terms of Service Privacy Policy
© 2026 WP Quick Search Inc. All rights reserved. ·
14 0.033s 4.25MB

Notice