Home
/
WordPress
/
How To Questions
/
How to change the domain of a WordPress Multisite?

How to change the domain of a WordPress Multisite?

To change the primary domain of your WordPress multisite installation, you need to update five values in the website’s database.

WordPress stores serialized data in the database and altering it can cause corruption, which is why a backup is a preventive option.

Checklist for Changing the Domain of a WordPress Multisite

We’ve prepared this checklist to make the multisite domain change easier for you. After this checklist, you’ll find the next section which goes into detail about how to change the domain of a WordPress multisite.

  1. Back-Up Your Website – Before making any changes, ensure you have a full backup of your site’s database.
  2. Access Database via PhpMyAdmin – This tool is essential for the steps below and is available on all SiteGround plans.
  3. Update wp_options Table:
    • Locate wp_options in your database.
    • Change the values of the “siteurl” and “home” lines to the new domain.
  4. Update the wp_site Table:
    • Modify the domain name in the wp_site table.
  5. Adjust wp_sitemeta Table:
    • In wp_sitemeta, update the “siteurl” entry.
    • Include “http://” or “https://” as necessary, with a trailing slash.
  6. Revise wp_blogs Table:
    • Change any old domain names in the “domains” column of the wp_blogs table.
  7. Edit Each wp_#_options Table:
    • For every subsite, represented by each blog_id in the wp_blogs table, update the “siteurl” and “home” in the corresponding wp_#_options table, where # is the blog_id.
  8. Domain Formatting Specifics:
    • In wp_site and wp_blogs, domains should not include “http://” or trailing slashes.
    • In wp_options, domains should start with “http://”.
    • In wp_sitemeta, domains should start with “http://” and end with a slash.
  9. Retain SSL and www Configurations:
    • Ensure the new domain maintains the same SSL (https or http) and www setup as the old domain.
  10. Modify Pre-defined wp-config.php Values:
    • Comment out any pre-defined WP_HOME and WP_SITEURL values in wp-config.php.
  11. Update Multisite Settings in wp-config.php:
    • Change the DOMAIN_CURRENT_SITE to your new domain.
    • Verify other multisite settings like MULTISITE, SUBDOMAIN_INSTALL, SITE_ID_CURRENT_SITE, and BLOG_ID_CURRENT_SITE.

Below you’ll find the steps needed to update the five values mentioned (the table prefix is shown as wp_ in the examples below).

How to Change the Domain of a WordPress Multisite?

If your database uses a different table prefix, replace wp_ in the following table names with your prefix:

  • wp_options: lines named “siteurl” and “home”
  • wp_site
  • wp_sitemeta: the entry named “siteurl”
  • wp_blogs: any entries in the “domains” column that have the old domain name
  • wp_#_options: Every sub-site will have sets of tables that correspond to the blog_id in the wp_blogs table. Navigate to the wp_#_options table, where # corresponds to the blog_id, and update the “siteurl” and “home” values in the table.

To update the information above, use PhpMyAdmin, which is available on all SiteGround plans. You can find more information on how to work with the tool in this tutorial.

Using the aforementioned steps – navigate to the necessary tables, which are mentioned above, and edit the URLs to the new domain you wish to set. Make sure that you are altering the URLs, exactly as they are. For example, if a table has only the bare name of the domain setup, you need to leave it, as it is:

mysite.domain.com                =>                 mysite.newdomain.com

If the domain value in the database includes HTTP, you need to keep this format:

http://mysite.domain.com                =>             http://mysite.newdomain.com

WordPress has strict rules for each field, depending on the table. The wp_site and wp_blogs tables can NOT include http:// or a slash at the end of the domain name. On the other end, the wp_options table is required to have the http:// at the beginning. In the wp_sitemeta table, you need to have http:// at the beginning and a trailing slash at the end.

If your website uses an SSL or is configured to work with its www version, you need to keep this setup. For example, if you have both SSL and the www domain setup, change it as in the example below:

https://www.mydomain.com             =>                   https://www.mynewdomain.com

As part of the domain update, you need to comment out any pre-defined values in your wp-config.php file, as they will override the settings in the database. For example:

define( 'WP_HOME', 'http://mydomain.com' );
define( 'WP_SITEURL', 'http://mydomain.com' );

Such lines should be commented with ‘#’ in front of the line so that they look like:

#define( 'WP_HOME', 'http://mydomain.com' );
#define( 'WP_SITEURL', 'http://mydomain.com' );

To edit the wp-config.php file, use your Site Tools > File Manager

IMPORTANT: In most cases, you will have to update an entry in your wp-config.php file. The code below will be present in the file, in these cases:

define('WP_ALLOW_MULTISITE', true);
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'mysite.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

Replace “mysite.com” with your desired new domain. For instance:

define('WP_ALLOW_MULTISITE', true);
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true );
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'newsite.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

Common mistakes when changing the domain of a WordPress multisite

One frequent mistake is not updating the domain details everywhere needed, leading to broken links. Make sure to change the domain settings in both the ‘wp-config.php’ file and the database for each site.

Also, it’s easy to overlook URLs embedded in your theme or plugins. Use a tool to find and replace these URLs to prevent any site disruptions. Don’t forget to clear your cache after these changes, otherwise, your site might still show the old domain’s data.

And importantly, always back up your entire Multisite before starting. This way, if something doesn’t go as planned, you can quickly go back to how things were.

Following these tips helps make your domain change smooth and hassle-free.

Share This Article