WordPress Toolkit Staging Domain Redirection Issue Workaround

Karl Is WrightUncategorized

WordPress Toolkit Staging Domain Redirection Issue Workaround

 

The Problem;

 

if you are running a Plesk Server with the powerful WordPress Toolkit, you may run into an issue where you clone a production site to a staging subdomain (or some other direction) and the toolkit lists, two identical domains, both of which redirect to your primary site.

So, after running the clone feature on production.com to clone a WordPress instance to staging.production.com

staging.production.com redirects to production.com

and production.com also goes to production.com

and the WordPress Toolkit lists the two sites as

production.com

production.com

 

The Solution:

So how do we fix this?

First ensure all your WordPress instances have the following lines;

define('WP_HOME', 'https://production.com');
 define('WP_SITEURL', 'https://production.com');

in the wp-config.php file of your WordPress Instance.

Doing this can prevent further issues with the clone feature, the Toolkit can automatically adjust the site URL contained within the file when you make a clone.

So it’s a good thing to do anyway.

 

To fix the duplicate URL listing in the WordPress Toolkit,

  • First find the ID’s of your Staging and Production WordPress Instances.
  • Go to the WordPress Toolkit Dashboard
  • Then move your mouse over the name of your WordPress Instance, no need to click

  • Now look at the link in the bottom right of your browser

The number at the end of the link is the ID of your WordPress instance. Get the ID for both your WordPress instances.

 

  • Login to the Plesk server via SSH.

First backup the database before you modify it.

# cp -a /usr/local/psa/var/modules/wp-toolkit/wp-toolkit.sqlite3{,.plsk_bkp}

 

  • Check the WordPress Toolkit sqlite3 database;
#  sqlite3 /usr/local/psa/var/modules/wp-toolkit/wp-toolkit.sqlite3

sqlite> SELECT name, value  FROM InstanceProperties where instanceId=[YOUR ID};

url|https://[your-url]

 

  • If the WordPress instance has the wrong URL, you can fix it.

 

sqlite> update InstanceProperties set value='https://[right-url]' where name='url' and instanceId=[YOUR ID];

 

Now go back and check your WordPress Toolkit Dashboard and see if the WordPress instances have the appropriate URL’s listed.