"Redirect loop" and "You do not have permission to access this page."

May 25, 2019 214 views
DigitalOcean WordPress

I have some problems and I have been trying for some hours but I can not. So I decided to ask here in the forum, maybe someone can help me and my doubt can also help other people.

This morning the droplet that was hosting my blog crashed and I could not get it to work again. As I had backed up the blog a few days ago with updraft, I decided to create a new droplet.

I created a new installation of Wordpress through Marketplace (one click), installed updraft again and migrated the database After migrating the database in the new droplet, I set up the domain again in the cloudflare, because I was not able to access the blog that was migrated with the links on https.

With this I was able to access the homepage of the blog and its articles, but the pages were a little messy.

When I accessed /wp-login.php I came across a redirect loop, and that loop was only on the login page.

So after doing some research I found the following code that I added to wp-config.php

define('WPSITEURL', 'https://www.example.com');
define('WP
HOME', 'https://www.example.com');
define('FORCESSLADMIN', true);
define('FORCESSLLOGIN', true);
if(isset($SERVER['HTTPCFVISITOR']) && strpos($SERVER['HTTPCFVISITOR'], 'https')){
$_SERVER['HTTPS']='on';
}

With this I have accessed the login page, but when typing the login and the password, the following message appears

"You do not have permission to access this page."

Now I can not access the blog administration page, I'm stuck out of the blog and I do not know what to do, can anyone help me with this?

I'll open a ticket, but it's taking a while to respond

1 Answer

Hey there,

What SSL mode do you have enabled in your Cloudflare control panel?
It is most likely that Cloudflare is attempting to fetch the http version of the page through its proxy, but wordpress is forcing it to https, which is then causing the redirect loop through Cloudflare when you access that page.

The quickest solution is likely to set FORCE_SSL_ADMIN and FORCE_SSL_LOGIN to false :)

  • I am using the Flexible ssl, when I leave the FORCESSLADMIN and FORCESSLLOGIN options false the redirect loop is caused.
    Now when I leave in true I have access to the login page, but when typing the login and the password appears the following message

    "You do not have permission to access this page."

    Accessing the homepage of the blog when you log in appears the wordpress admin bar, but when you access it again the message "You do not have permission to access this page." pops up.

    Then I get locked out of wordpress

    can it be because of different versions of the database or this has nothing to do

    I migrated the blog with the intention of solving my problems but these appeared.

    Help me

    • Oh, how odd.
      Honestly, I don't use WordPress so I'm not completely sure what the answer is then, I was under the impression that you simply had a Cloudflare proxy issue occurring.

      Silly question but have you tried accessing the site in a different browser or incognito mode to see if that resolve the login issues?

      I doubt this is anything to do with the database migration as you are able to log in but then it fails after that. If the database was the issue, I would imagine you wouldn't be able to log in or access the site at all.

Have another answer? Share your knowledge.