Wordpress Domain Change

WordPress reacts interestingly to domain changes and will try to "help you" by sending you to the previous official domain (even if you no longer want to use it).

There are different ways to handle this, some more involved than others.

The combination of settings, themes, plugins, content and customizations will determine the best method. It is not possible to recommend in advance.Note: Migrating from your original.domain.com to test.stackos.io, then from test.stackos.io to real.stackos.io are two domain name migrations.

Method 1:

Allocate a second set of servers and use migration tool to smooth out any domain changes in the database, plugins, and themes

Example: Migrate from test.domain.com to real.domain.com

This is a reasonable strategy if you already are familiar with migrations and want to do it again

For example, if you already migrated from real.domain.com -> test.domain.com

And now you simply want to do it again from test.domain.com -> real.domain.com

If both test.domain.com and the new real.domain.com are both on StackOS, be sure to have enough resources to run both sets of pods at the same time.

For guidance, check this link: StackOS Wordpress Migration Guidance

Then search for: "Trying to migrate an existing test/production site?"

Method 2:

Try to see if a domain name change only will be sufficient (may require additional database edits after)

Try to see if overriding the domain in the config is enough to stop the wordpress redirect. This will depend on all your plugsins/themes/database data cooperating which varies case by case.

To be clear, this is not a StackOS issue. You would encounter this issue if you were switching domains on a traditional server.

webtty and exec a shell into your wordpress pod

Then set the following overrides in wp-config.php by doing the following: You will need to install an editor

apt update

apt install -y nano vim

Use the editor you know (nano if you don't know)

nano wp-config.php

Search for this line:

/* Add any custom values between this line and the "stop editing" line. */

// Define wp home and site url

define('WP_HOME','https://MYDOMAIN.COM');

define('WP_SITEURL','https://MYDOMAIN.COM');

Save your edits (Control+X in nano). Test your site again.

If some things work and other things don't, then you'll need to either consider

  • Method 1 - Migration as above

  • Checking each plugin/theme/content piece to determine which item is "stuck/hardcoded" for the previous domain

Last updated