Fix WordPress Cloudflare HTTPS Redirect Loop

If you use Cloudflare flexible SSL certificate to use HTTPS, in some case you may get redirect loop.

I believe it is caused because WordPress does not recognize the “fake” SSL certificate.

Fixing it is simple.

Open your wp-config.php file, and find this first line

<?php


After that line, you can add this PHP code

$_SERVER['HTTPS'] = 'on';

In my case, i modified it into this :

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

Now wordpress should work properly 🙂

Comments

Leave a Reply

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