I recently came across an issue with my WordPress installation. It’s situated behind a load balancer where SSL is terminated. The load balancer takes HTTPS traffic, then forwards it as HTTP on port 80 to the wordpress server.
I was running issues with a redirect loop after installing wordpress. The solution was to add this bit of code to wp-config.php:
define('FORCE_SSL_ADMIN', true); if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') $_SERVER['HTTPS']='on';
This solves the redirect loop issue but then I ran into a different problem. When I tried to sign into wp-admin I would get this message:
Sorry, you are not allowed to access this page.
After much digging I found this post which emphasizes that you must place that code BEFORE anything else in wp-config.php (except for the beginning PHP tag.) Success!