Moving Multisite to a New Domain (Without Errors!)
If you’ve finally bought the domain you’ve had your eyes on for some time or you’ve found an even better one for your Multisite network, you’ll need to make some adjustments to your WordPress installation before you can use it.
If the physical location of your Multisite suits you fine and you don’t need to switch servers – just your domain – then this handy guide is for you. Moving the domain of your Multisite network isn’t as straightforward as moving a single install, but it’s still possible to make the switch.
The process isn’t yet fully automated so you’ll need to edit your database and files, but you can use plugins to significantly speed up the process.
Moving your Multisite’s domain doesn’t have to be a difficult. Today we’ll cover how to easily make the switch – and without error.
Before we begin, backup your entire site. This includes both your files and databases. This is a WordPress best practice to ensure your site will remain safe and can be restored if you make a mistake.
Quick File Edits
Locate your wp-config.php file in the base of your install and find the following snippet of code:
Not too far above that line, you’ll find the following code. Change the
'DOMAIN_CURRENT_SITE', 'yourdomain.com' to list the new domain you wish to use by replacing yourdomain.com
Below this code, add the following two lines, and be sure to replace your-new-domain.com with the actual domain you wish to use. Be sure to also add it above the line “That’s all, stop editing!”
Adding the www. prefix is entirely up to you. The only difference between adding it in or leaving it out is just the way it looks in the address bar. It’s simply a style choice.
If your new domain name has an SSL certificate assigned to it, be sure to type https:// with your domain rather than the default http:// to make sure visitors are automatically directed to your secure site.
We’re almost done, but in order for the changes to really work you also need to update your database tables. This is the most important part. If you get it wrong, it could completely break your site. No pressure!
Edit Your Datatbase
This is the most difficult part of the process. You’ll need to know some key information before you’re able to make the necessary changes.
If you don’t remember your login details, they can be found in your wp-config.php file and will look similar to the code below. You will find your username listed beside DB_USER and your password beside DB_PASSWORD, both in quotations.
The name of the database that holds your site will be listed beside DB_NAME. You will need to know this in order for the changes to work.
For a quick reference, this is a list of the main tables you will need to update with your new domain name:
- wp_options > siteurl
- wp_options >home
- wp_sitemeta > siteurl
- wp_blogs > domain (change this for all instances that use your old domain)
- wp_#_options > siteurl (the “#” refers to the blog ID of additional sites in your network)
- wp_#_options > home
- wp_#_options > fileupload_url
If your network is large, you’ll need to sift through multiple pages. If this is the case, you’ll see the page navigation listed under the search box and your database name.
Login to phpMyAdmin through cPanel and find your database name on the left-hand side in the menu and click on it. This will populate the main content area with a list of all your tables.
Find the table called wp_options and click on its name. If you changed the prefix of your database tables, it will not appear as the default wp.
Another list will appear and in it find the option_name called siteurl. Click on its “Edit” link and change the domain to the one you wish to use.
Don’t forget to keep the http:// in front of the domain or https:// if you have an SSL certificate attached to the domain. If you do not include one of these, your site will not work.
Once you’ve made the necessary changes, make sure “Save” is listed in the drop down box below the text field and click the “Go” button to save your changes.
Once you’re back to the previous page, follow the same steps for the other tables that are listed above.
1.6 million WordPress Superheroes read and trust our blog. Join them and get daily posts delivered to your inbox - free!
Search and Replace for Other Tables
This is the trickiest part. You will need to replace other instances where your database tables refer to your old domain.
Start by making sure your database is selected and not one of its tables. Click the “Search” tab at the top of the page and enter your old domain name into the “Words or values to search for” field.
Under “Find,” select the radio button for “the exact phrase,” and “Select All” under the “Inside tables” field. Finally, click “Go” on the bottom, right-hand side of the page.
You’ll see a full list appear with all the tables in your database. The results which have matches listed are the tables that require editing, just as we covered in the last step.
When you find a search result with a number higher than zero beside the word “matches,” go ahead and click the browse button on the right of the listed item to see the full table with the values that need changing.
Don’t forget that all image links and the upload path need to be changed in order for images to be visible on your site so pay special attention to these areas in your tables.
There are a few tables – listed below – that don’t require any changes, even if they are listed in the search results. If you edit them, you will break your site. If you would like more information on this, visit Changing the Site URL in the WordPress Codex.
- dashboard_incoming_links (this has been unused since version 3.8 so you won’t see this in newer installs)
- wp_posts > guid
It’s also possible to search and replace all instances of your old domain with a plugin. It saves a lot of time and also ensures you don’t make – or miss – any changes that will wreck your site.
Search and Replace is a plugin that is regularly updated and is also completely free. While the search options are straight forward, be sure to review them carefully before making any changes as choosing the incorrect options can cause your site not to work.
Be sure to use the “Search for” and “Replace with” text fields at the bottom of the options page for the best results.
WP Migrate DB is another plugin that is regularly updated and it’s also incredibly easy to use. The only drawback is that using it with Multisite is a premium option.
There are many other plugins that are wonderful and work really well. These ones are simply plugins that I have used successfully in the past so I know they work. Use whatever option that you like the best.
Make sure your new domain’s DNS records point to your site’s IP address. Each hosting company is a little different so be sure to ask them for assistance if you’re not sure how to update these records yourself.
If you have a sub-domain install of Multisite, be sure wildcard domains are enabled in your new domain. This will ensure new sites are created without error.
Update Your 301 Redirects
This is the final step which may not apply to you. If you haven’t made any custom changes to your .htaccess file, then you’re done!
If you have made changes to this file, such as by adding permanent URL redirects, you will need to update them to replace your old domain name with your new one. Below is an example of what you need to edit.
Just be sure to replace the example links as well as your-new-domain.com to the actual URLs you wish to redirect.
After you’ve done this, you’re all set to go. You can now go to your new domain and see your site.
Moving your Multisite to a new domain doesn’t have to be difficult or time consuming and these steps should set you up for success. If you find something goes wrong, you can restore your site and try again.
You can also find more detailed information on moving your domain, you can check out the Changing the Site URL page in the WordPress Codex.
If you need to migrate your entire site to a new server or hosting company, you can find detailed instructions in our post How to Safely Move Your WordPress Site (Without Losing Anything!).
Have you used any plugins or tools for moving your Multisite domain? Which one is your favorite? Share your experiences and top picks in the comments below.