wp-admin redirecting to https, denying login

I use cloudflare via the cloudflare plugin, have SSL enabled.

Enabled ssl within the wp-config.php file:

define('WP_HOME','https://example.org');

define('WP_SITEURL','https://example.org');

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

Everything seems to work fine on the main site, but when trying to login to admin I see:

You do not have sufficient permissions to access this page.

This started after going into general settings and adjusting the ‘Home’ and ‘Site URL’ options.

Following guides, I am able to get the page to appear (instead of being stuck in an infinite redirection loop).

I’m not sure what else to change here, as I’ve just lost permissions out right after switching to https everywhere.

2 Answers
2

You need to forward the http:// to https:// to avoid infinite loop.

if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
   $_SERVER['HTTPS']='on';

Leave a Comment