How to change the domain of a WordPress Multisite

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

Bear in mind, that if you have a Dedicated server and you have not purchased the backup service, it is recommended, to backup the database. You can do that by following the steps in the article here.

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

Below you can 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. You need to 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, you can use PhpMyAdmin tool, that is available on all SiteGround plans. You can find more information 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:

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

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, you need to keep this, as in the example below:

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:

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

To edit the wp-config.php file, you can use the cPanel => File manager tool. You can find more information how to work with the tool in the tutorial here.

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:

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

 

You find this article useful? Click here to learn more about SiteGround web hosting experts and what else we can do for you!