Too many Redirects after switching WordPress to https

I have soved the issue using the below code inside wp-config.php

define('WP_HOME','https://mywebsite.com');
define('WP_SITEURL','https://mywebsite.com');
$_SERVER['HTTPS'] = 'on';

I had same problem nginx and had to do following in .htaccess

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]

in wp-config.php

define('FORCE_SSL_ADMIN', true);
define('RELOCATE', TRUE);
$_SERVER['HTTPS'] = 'on';
define('WP_HOME', 'https://yourdomain.com');
define('WP_SITEURL', 'https://yourdomain.com');

don't use the below with nginx unless you make sure it passes HTTPS is on to fast cgi, otherwise it won't work,

if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
    $_SERVER['HTTPS'] = 'on';
}

it might be of benefit log debug level in error log of nginx, this is how you get to see the flow.


Make sure that you define the WP_SITEURL and WP_HOME at wp-config.php

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

And add this condition to check if the https at wp-config.php

    if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
        $_SERVER['HTTPS'] = 'on';
    }

Make sure that you define the WP_SITEURL and WP_HOME at wp-config.php

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

And add this condition to check if the https at wp-config.php

if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
    $_SERVER['HTTPS'] = 'on';
}

This works well