How to Change the Network Domain of a Multisite WordPress Installation

You have a domain that’s the main domain hosting several other domains, using WordPress’ Multisite feature. You want to change that main domain, perhaps because you’re selling the domain or using it for another purpose, or want to move it to a non-multisite server, or want to use a different CMS, or no CMS at all. How do you promote a different domain to become the primary domain of a multi-site WP installation?

I had to do this with my old blog, riceball.com. The process was complicated.

These instructions explain how to change the primary domain for a network of sites. In my case, riceball.com was the old domain, and technote.fyi was the new domain. technote.fyi was turned into the primary domain.

These instructions do not explain how to change the domain for the primary site. The old primary site was riceball.com and had hundreds of pages, and the new one, technote.fyi, was empty. At the end of this process, riceball.com was still hundreds of pages, and technote.fyi was still empty.

First off, I had to switch the multisite feature on. That’s documented everywhere. SSH into the server and edit wp-config.php.

Second, I had to get the new domain, technote.fyi, and then create a site for it. Once that’s working, you need to do some tricky stuff.

Third, SSH into the server and fire up the mysql console. You can also use phpMyAdmin, but I used the console.

Look for the new blog’s ID.

mysql> SELECT * FROM wp_blogs;
+---------+---------+--------------+------+---------------------+---------------------+--------+----------+--------+------+---------+---------+
 | blog_id | site_id | domain       | path | registered          | last_updated        | public | archived | mature | spam | deleted | lang_id |
 +---------+---------+--------------+------+---------------------+---------------------+--------+----------+--------+------+---------+---------+
 |       1 |       1 | riceball.com | /    | 2019-06-18 09:24:11 | 2019-06-21 00:47:00 |      1 |        0 |      0 |    0 |       0 |       0 |
 |       2 |       1 | technote.fyi | /    | 2019-06-18 16:28:31 | 2019-06-18 18:40:20 |      1 |        0 |      0 |    0 |       0 |       0 |
 +---------+---------+--------------+------+---------------------+---------------------+--------+----------+--------+------+---------+---------+

The ID we want is 2, for technote.fyi.

Peek into wp_site, with:

mysql> select * from wp_site;
+----+--------------+------+
 | id | domain       | path |
 +----+--------------+------+
 |  1 | riceball.com | /    |
 +----+--------------+------+

Alter that. Change the domain:

update wp_site set domain='technote.fyi' where id=1;

That’s it. No need to change the ID.

Go into wp-config.php and edit a few lines. Old lines are commented out:

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
// define('DOMAIN_CURRENT_SITE', 'riceball.com');
define('DOMAIN_CURRENT_SITE', 'technote.fyi');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
// define('BLOG_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 2);

You should not need to change the siteurl and home values in wp_options. If you need to, for some reason, you can do it within the MySQL console.

The options are called ‘home’ and ‘siteurl’, and you can peek at them like this:

mysql> select * from wp_options where option_name='siteurl' or option_name='home';
 +-----------+-------------+---------------------+----------+
 | option_id | option_name | option_value        | autoload |
 +-----------+-------------+---------------------+----------+
 |         2 | home        | http://riceball.com | yes      |
 |         1 | siteurl     | http://riceball.com | yes      |
 +-----------+-------------+---------------------+----------+

The options for the second site (technote.fyi) are in the table wp_2_options.

Edit the values with SQL updates, if necessary. They should match the domain. You should not need to change them.

Leave a Reply