How to change the domain of a WordPress Multisite?
Table of Contents
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.
- Back-Up Your Website – Before making any changes, ensure you have a full backup of your site’s database.
- Access Database via PhpMyAdmin – This tool is essential for the steps below and is available on all SiteGround plans.
- Update
wp_options
Table:- Locate
wp_options
in your database. - Change the values of the “siteurl” and “home” lines to the new domain.
- Locate
- Update the
wp_site
Table:- Modify the domain name in the
wp_site
table.
- Modify the domain name in the
- Adjust
wp_sitemeta
Table:- In
wp_sitemeta
, update the “siteurl” entry. - Include “http://” or “https://” as necessary, with a trailing slash.
- In
- Revise
wp_blogs
Table:- Change any old domain names in the “domains” column of the
wp_blogs
table.
- Change any old domain names in the “domains” column of the
- 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 correspondingwp_#_options
table, where # is the blog_id.
- For every subsite, represented by each blog_id in the
- Domain Formatting Specifics:
- In
wp_site
andwp_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.
- In
- Retain SSL and www Configurations:
- Ensure the new domain maintains the same SSL (https or http) and www setup as the old domain.
- Modify Pre-defined wp-config.php Values:
- Comment out any pre-defined
WP_HOME
andWP_SITEURL
values inwp-config.php
.
- Comment out any pre-defined
- 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
, andBLOG_ID_CURRENT_SITE
.
- Change the
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.