As time goes by, there may come the case that you find a better domain and want to transfer your multisite to it. Unlike moving a single WordPress install, transferring a multisite to a new domain is a little bit tricky and cannot be automated, so you need to take some manual works in your website files and databases.
However, there is no need to be scared, because the entire process is not as difficult as it is heard to be. As long as you strictly follow the instructions offered below, it’s probable that no error will occur. One thing you need to pay attention is that this tutorial is only prepared for those who just change the domain without switching between servers.
Before starting out, you must make the following preparations, or your site might not work properly – even getting broken.
- Back up your website completely, including all the files and databases. This ensures that you can recover your site if an error appears.
- Make sure that you have enabled wildcard domains if your multisite uses a subdomain install.
- Make sure you have updated the DNS records of your new domain in the case that the domain is not registered with your hosting provider. If there is any problem when doing this, contact your web host for help.
Now, let’s begin to transfer a WordPress multisite to a new domain.
Step 1: Edit the wp-config.php File
This is the first and the easiest step. Also, if you want to deal with the difficult things first, you can jump to Step 2 to get the necessary database tables updated, and then come back to this step to edit the wp-config.php file.
Firstly, you need to locate the wp-config.php file in the root folder of the multisite install with a web-based file manager or FTP. Then, open the file and find the following line. “yourdomain.com” should be the current domain of your multisite.
Now you need to replace “yourdomain.com” with the new domain name. After doing so, find the following line of code.
Next, you need to add the code below above the “stop editing” line. Remember to replace the “newdomain.com” with your own domain.
You can choose whether to add “www.” by yourself, depending on whether you need the prefix to show in the address bar of web browsers. But the “http://” must be added, and if an SSL certificate has been installed on the new domain, you need to replace “http://” with “https://” to direct visitors to the secured site.
At last, save the changes.
Step 2: Update the Database Tables
Updating database tables is the trickiest yet the most important part of the transfer, but if you have access to phpMyAdmin, the editing should be much easier. However, before touching any database table, we must remind you one more time that you have to make a full backup of the database.
To save your time, this step can fall into two parts – manually editing the tables that cannot be handled in bulk, and then bulk search and replace the domain instances in all other tables. Details are discussed in below.
A small note: If you ever have the need to log into your database but forget the login credentials, don’t worry, because you can find the database name, username and password easily in the wp-config.php file.
Edit database tables manually
Assumed that phpMyAdmin is available, you can log into it and access the database of your multisite. If you have multiple databases under management, make sure you have selected the right one to open.
Firstly, locate the wp_options table and open it. Note that your tables may not begin with “wp_” if you have changed the prefix to a custom one.
Under the option_name column, find siteurl and home. You need to update the two rows one by one by clicking on the “Edit” link.
In the option value, you just need to change the old domain to the new one.
On the bottom left of the page, you need to select “Save” from the drop-down, and for the action taken after the changes are saved, select “Go back to the previous page” so that you can come back to the list and edit other rows. Then, click on “Go”.
When you have finished wp_options, you also have to edit the following tables with the same steps to make sure that the old domains are replaced by the new ones.
- The domain field in wp_site and wp_blogs
- siteurl in wp_sitemeta
- home, siteurl and fileupload_url in all of the wp_#_options tables. “#” is the blog id of the sites in your multisite network.
After these tables are done, you still need to move on to all other tables that include domain information. Editing each of them manually requires a huge workload, but fortunately, there are quicker ways – to use the search function in MySQL, or to use a plugin.
Search and replace the instances in other tables manually in MySQL
This option is suitable for those who are very careful about database changes and would like to have everything under control. Those relying less on plugins should also try this approach.
First of all, make sure that you are landing in the database itself instead of any of its tables. Then, click on the “Search” tab in the top menu. Here you can see a search page on which you need to take the following actions.
- Enter your old domain in the blank field for the words/values that need to search for.
- Select “the exact phrase” for the “Find” option.
- Click on the “Select All” link next to the drop-down for “Inside tables”.
After clicking on the “Go” button located in the bottom right of the page, you will get a list of all database tables, and the number of matches is also shown. Those tables with matches to your old domain are the ones that need editing.
Clicking on the “Browse” link of any table with matches, you can see all the values included in the table which require to be edited. Going through those tables requires some time, and you must be very careful when changing the domain information. Also, do not forget the upload path and the image links, or you might get numerous broken images on your site.
However, there is one exception that you have to pay attention to. If you find any instances of the old domain in the “guid” column of the wp_posts table, leave them untouched. In WordPress Codex, it is suggested that all the contents in the GUID column are critical and should never be changed.
Update tables with a plugin/tool
This method is for those who want an extremely quick and energy-saving way for changing instances in database tables. There are a number of good choices, and below are two of the best.
- Better Search Replace – It is an actively maintained plugin that supports serialization for all tables, and allows you to select/unselect certain tables. The free version is easy-to-use and powerful enough, but if you want premium features like change history, support from the developer or custom profiles, you can also purchase the Pro version.
- Search Replace DB – It is a great search and replace tool with which you can modify a string in a database quickly and effortlessly. “Dry run” and serialization are also supported. But before using it, you have to install it manually in a new subfolder of your WordPress site.
Using a plugin or an automated tool is quick and easy, but still, you need to review the options and changes carefully to make sure you are not making any mistake. Also, be sure the automated process will not touch GUID.
Step 3: Update the .htaccess File If Necessary
You’re almost done. But if you have made some custom changes to the .htaccess file such as adding 301 redirects, you will need to get into the file and replace any of the old domain information with your new domain. When you have finished this small task, you should be able to see your WordPress site by typing the new domain in the address bar.
Transferring a multisite to new domain is not that hard as every single step can be under full control. As long as you have kept a good and complete backup, you can have a try at any time.
Also, if you want to migrate a site to another physical location, you can follow our detailed instructions about how to move a WordPress site to a new server.