How to Change a WordPress Multisite Primary Domain
If you want to change the primary domain of your WordPress multisite installation, there are 5 values to change. There is no need to perform a database dump. This is actually frowned upon, as WordPress stores serialized data in the database, and altering it can cause corruption.
Here is a list of the 5 main tables and options that need to be changed:
- wp_options
Select the options table and look for the entries named “siteurl” and “home” - wp_site
- wp_sitemeta:
Select the option named "siteurl" - wp_blogs:
Select any entries in the "domains" column that have the old domain name. - wp_#options
Each sub-site will have sets of tables that correspond to the blog_id in the wp_blogs table. You need to go to the wp#_options table, where # corresponds to the blog_id, and update the "siteurl" and "home" settings in that table.
Be sure to comment out any pre-defined constants in your wp-config.php file, as they will override settings in the database. Constants referring to your URL resemble the following lines of code:
define( 'WP_SITEURL', 'http://example.com' );
In most cases you will need to update an entry in your wp-config.php file. The following code provides a common configuration example:
define('WP_ALLOW_MULTISITE', true);
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'old.siteurl.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
On the line that has “define(‘DOMAIN_CURRENT_SITE’,'old.siteurl.com’);”
You will replace “old.siteurl.com” with your domain. So for example:
define('WP_ALLOW_MULTISITE', true);
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'newdomain.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );