Too many redirects after restoring wp site on new server

Moving from > VM 6.16 Pro (opps, expired at the moment) on an Ubuntu Linux 16.04.7

Moving to > 6.17-3 GPL on an Ubuntu Linux 20.04.3

Wordpress (5.7.3) has been bugging me for a php update, says the current php 7.0.33 is insecure.

So I finally break down and start moving my sites to the new server with php 8.0.11.

First site restores on the new server with no problems.

Second Wordpress site… after backing up and restoring the virtual server on the new machine, I get - “too many redirects”

So I go through forums and try to figure out what’s causing that. I’ve disabled plugins, changed themes, erased .htaccess, backupped, transferred, restored, several times with different changes. Nothing has made a difference.

So I wondered if the core wp files were getting corrupted somehow… so I went to the Virtualmin ‘install scripts’ and tried to update the site’s WP files to the current version.

Interesting… it won’t do it. I get an error:

Upgrading WordPress to version 5.8.1 … failed dependencies : PHP version 5.6.20 or later is required, but this virtual server is using version 7.0

Well, actually, the new server is using php 8.0.11. I checked the options in VM and switched it down to 7.4.1, which is the lowest available on this server. It didn’t make any difference, go the same error. Either way though, both are “5.6.20 or later”.

Could this issue be related to the “too many redirects” problem?

Any suggestions on where to go from here?

Thanks,

Chris

hi I can help with the issue but how did you get PHP 8 on that version of Ubuntu if I may ask?

if you interested I can pm you costs involved otherwise said this is totally unrelated to virtualmin or webmin. anyway you let me know and have nice day.

Installed as per: Multiple PHP Versions – Virtualmin

php 8 is the problem. Run 7.4 and you will have no issues at all.

For the life of me I don’t get why people go from not upgrading for 4 versions jumping straight to the latest that just came out and isn’t compatible with half the plugins you’re probably using.

Thanks for your thoughts Gomez.

As mentioned above, I disabled all plugins, and switched themes (to 2021), and set the virtual server for this domain to 7.4.1, and all had no affect and I continued to get ‘too many redirects’. The redirects are 301s repeatedly back to the same page,

Chris

PS, I should mention I can’t reach the front or back end of the WP site. I get the ‘too many redirects’ issue on both. Each change I made (disabling plugins, changing themes) was done on the old server, then I backed everything up, deleted the previous non-working virtual server, restored the new backup, and tried again, but with the same results.

  1. Are you using Cloudflare?
  2. Do you have a link we can try so we can see if it’s a caching problem on your end?
  3. Have you checked your functions.php file to make sure your settings are correct (name of web address is actually right and hasn’t changed.)

1)Yes, I use Cloudflare, in development mode when I was testing.

  1. No, I had to switch back to the old server for now, so the site would be up. But it’s not a caching problem. I tested in incognito mode, a redirect checker and Search Console.

  2. Yes, changing to the 2021 would have cleared any issues if there was something causing a problem in the normal theme’s functions.php. I checked through wp-config as well and it’s all standard.

Been a frustrating issue :slight_smile:

Well, can’t help you then other than to guess at what you did.

I’m betting what you did was when you installed Wordpress you did it with the default settings and it put the install in a wordpress folder rather than top level.

If your present site is at top level then that would change the web address and give you the redirect errors because your website wouldn’t be correct.

So if your site right now is mysite.com and you moved it to a new virtual server with the default install of Wordpress it would put it in a wordpress folder so your new address would be mysite.com/wordpress.

But your restore would still have the settings of mysite.com, so it would never make it to the actual address of mysite.com/wordpress.

But again, with zero information on what the site is and what you actually did, that’s just a guess. But it is a common issue many people inadvertently fall into.

You would lose the bet.

This was not a case of me installing Wordpress and moving content onto it.

It was me backing up the Virtualmin virtual server and restoring it on the new server, then pointing the dns to it.

I’m not blaming Virtualmin for the issue… I don’t know where the issue lies. But backing up and restoring Wordpress on an updated server, when I know that Wordpress works on that server, and I’ve disabled plugins and have the default theme in place - should just work. It should be pretty effortless. I’m sure that’s the intention.

I don’t know how you can say that I’ve given you zero information on the site and what I’ve done. I’ve told you exactly what I have done.

As for seeing the site… there’s nothing to see other than ‘too many redirects’ and what I’ve told you, it keeps 301 redirecting back to itself (screenshots attached). It’s not like you can see, get around the redirects, or discover anything more by looking at it than what I’ve told you,

Chris

Okay, I found a solution, though I don’t understand why this works.

On is_ssl in the WP docs, a commenter wrote that is_ssl does not work on sites behind load balancers or reverse proxies.

They suggested adding this code to wp-config.php

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

My site isn’t behind a load balancer or reverse proxy, but I wondered if it was an ssl issue, so I tried it… and now the site comes up fine. If I remove it, the redirect happens again.

Glad to have a solution, but I certainly wish I knew why it was required so I could fix the issue at its source. It wasn’t required for the other virtualmin server with Wordpress I moved over.

If I look up X-Forwarded-Proto there are a lot of references to nginx, but I have a normal lamp stack that was installed by Virtualmin as I set up the server (Ubuntu 20.4 on linode),

Chris

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.