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.

Below find the steps needed to update the five values mentioned (table prefix is shown as wp_ in the examples below. 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: As 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, that 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, it 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 it 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: Most of the 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 );

 

Share This Article