Changing the primary domain in a WordPress multisite installation

This article describes how to change the primary domain in a WordPress multisite installation. You may need to do this, for example, after migrating a site to a new server.

This article describes how to change the primary domain in a WordPress multisite installation. You may need to do this, for example, after migrating a WordPress site to a new server.

Changing the primary domain

To change the primary domain in a WordPress multisite installation, you must update several database entries and a setting in the wp-config.php file. The following procedures demonstrate how to do this.

Step 1: Update the database

To change the primary domain for WordPress multisite, you must first update several database locations. To do this, follow these steps:

  1. Log in to cPanel.

    📘

    Note

    If you do not know how to log in to your cPanel account, please see this article.

  2. On the Tools page, in the Databases section, click phpMyAdmin:
    cPanel - Databases - phpMyAdmin icon

  3. phpMyAdmin opens in a new page. In the left sidebar, click the WordPress database (in the image below the database is named example_wp922 ). A list of tables in the database appears:
    phpMyAdmin - Sidebar

👍

Tip

Typically, the WordPress database is
username_wpXXX or
username_a2wpXXX , where
username represents your cPanel username, and
XXX is a three-digit number.

  1. In the left sidebar, click the wpXX_blogs table:
    phpMyAdmin - Sidebar - Blogs table

📘

Note

XX is a random two-letter prefix used in the database table names.

  1. In the domain column, for each row, double-click the value, type the new domain name, and then press Enter:
    phpMyAdmin - Blogs table

  2. In the left sidebar, click the wpXX_options table:
    phpMyAdmin - Sidebar - Options table

  3. In the siteurl and home rows, in the option_value column, double-click the value, type the new domain name, and then press Enter:
    phpMyAdmin - Options table

  4. In the left sidebar, click the wpXX_site table:
    phpMyAdmin - Sidebar - Site table

  5. In the domain column, double-click the value, type the new domain name, and then press Enter:
    phpMyAdmin - Site table

  6. In the left sidebar, click the wpXX_sitemeta table:
    phpMyAdmin - Sidebar - Sitemeta table

  7. In the siteurl row, in the meta_value column, double-click the value, type the new domain name, and then press Enter:
    phpMyAdmin - Sitemeta table

  8. If you have added additional sites, then the database contains additional tables named wpXX_2_options,wpXX_3_options, and so on. For each of these tables, change the siteurl and home values as you did in step 7.
    phpMyAdmin - Sidebar - Second site options table

  9. The database is now configured to use the new primary domain, and you are ready to update the wp-config.php file.

Step 2: Update the wp-config.php file

To update the wp-config.php file, follow these steps:

  1. On the server, open the wp-config.php in your preferred text editor.

  2. Locate the line that contains the DOMAIN_CURRENT_SITE setting:

define( 'DOMAIN_CURRENT_SITE', 'example.com' );
  1. Replace example.com with the new primary domain.

  2. Save your changes to the wp-config.php file. The domain change is now complete.

More Information

For more information about the WordPress multisite feature, please visit https://wordpress.org/documentation/article/create-a-network/.

Related Articles