Fix WordPress “Sorry, you are not allowed to access this page.”

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!

4 thoughts on “Fix WordPress “Sorry, you are not allowed to access this page.””

  1. OH MYYYYY LOORRRRRRRRRRRRRDDDDDDDDDDDDD

    I’ve spent two hours with this issue and this is the answer! Just to clarify the code needs to go after <?php in wp-config.php. You have a typo saying its wp-admin

Leave a Reply

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