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.

Basic Housekeeping

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.

There are many tools that can help you do this such as our Snapshot plugin, VaultPress, or manually via FTP. Once you have everything backed up, you can continue to the next step.

 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_site
  • 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.

Your tables are loaded in phpMyAdmin when your database name is clicked in the menu
Keep in mind that if you have multiple databases under one single user, you will need to click the “+” button beside your username to find the database for your Multisite install.

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.

Click the edit button on the same line as siteurl to change it
In addition to clicking the edit button, you can also double click the option_name to open the editing page. Use whichever method is most comfortable to you. Don’t forget to save your changes.

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.

You can save the database table by clicking the "Go" button at the bottom of the page
You can also choose what the next action will be once the table is saved. I have selected “Go back to previous page” since there are more changes that need to be made.

Once you’re back to the previous page, follow the same steps for the other tables that are listed above.

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.

The search tab in phpMyAdmin  allows you to search all tables when your main database is selected
Make sure to keep the “Inside column” field blank to make sure your whole database is searched rather than specific values inside each table.

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.

Search results page in phpMyAdmin with the number of matches listed on the left of each table
A really long list will appear once you performed a search so make sure you scroll down to the very bottom to make sure you have found everything that needs to be changed.

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 brake 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

Using Plugins

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.

The "Search for" and "Replace with" text fields at the bottom of the Search and Replace plugin options page
Don’t forget to check all but one table in the “Search in” section above these fields. Leave “GUID” unchecked, otherwise, it will break your site.

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.

Additional Configurations

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.

Conclusion

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. 

14 Responses

    Michael Bissett

    Hey ChuckS,

    If it’s a new IP, you’ll need to update your db-config.php to reflect the new IP address.

    As for the databases themselves, if every database is in the same cPanel account, you could try doing a cPanel backup, or running a terminal command to backup the all of the databases.

    Search & Replace will search all tables for every blog inside the main database, but it may not reach out to the databases created by Multi-DB (haven’t tested that personally).

    You may need to manually back up each database, and then change the db-config.php file, updating the entries (database users, passwords, database names) to reflect the ones on the new server.

    You may wish to have someone handle the migration of this for you, like one of our Pros:

    http://premium.wpmudev.org/wordpress-development/

      Jenni McKinnon

      Hey,

      I completely agree, but wanted to add it in there for completeness. That’s also why I added a whole section about using plugins for searching and replacing instead of doing it manually.

      Thanks for posting more plugin alternatives. You’re fantastic! I’m sure they’ll help others.

      Cheers,
      Jenni

    Raevenne

    Rather than manually updating the database, you’d be better off using this:

    https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

    Interestingly enough, I just did this whole process two days before this was posted. It’s not hard, there are just a lot of steps, and if your host doesn’t quite have it together (mine didn’t) and doesn’t get some of the settings right on the dedicated IP, there can be issues. Using that script from Interconnect/IT made it MUCH easier than it would have been if I’d been trying to update the database manually though.

      Jenni McKinnon

      Hey Raevenne,

      I definitely agree! Using plugins and other tools to handle the search and replace for databases is way better. I just wanted to mention it for completeness.

      That’s very true, your hosting company needs to have all their ducks in a row. I’m glad you were able to get through it easily.

      Thanks for posting another search and replace alternative. You’re fantastic!

      Cheers,
      Jenni McKinnon

    wordev

    Hi Jenni
    Thanks for this great post, every time i think i almost know everything i need to know about multisite, i new post like this, “take me back to the earth”( spanish statement) in order to say to me ” man, you need to learn more…:))”
    OK. I have a couple of doubts ( from a novice:))
    1º the edition of the config file is in the old one or in the new one? I supose that i have one multisite already created with a bunch of sites in it, and i want to migrate to another multisite recently created from scratch in another domain, in the same host. So in which one do i edit the config file, with the steps listed above.
    2º Related with the search an replace, i was watching the plugin given by one fellow above (https://wordpress.org/plugins/better-search-replace/.) and apparently looks like fine. And my question is…May i do all the searching and replacing of all my database with the plugin, or do i have to do something manually? And when i do this process, is this done for main main site (where the multisite instalatin is done) and all the other subsites?

    Thanks very much Jenni for your help

      Jenni McKinnon

      Hey wordev,

      I know what you mean. :) There seems to be loads to learn when it comes to WordPress.

      To answer your questions:
      1. If you’re also migrating your Multisite, the easiest and best way to go about this is to save the wp-config.php file of your fresh install (with the new domain name already typed in). I wrote a post for migrating Multisite that you can check out here for more details: http://premium.wpmudev.org/blog/migrating-wordpress-and-multisite/

      2. Yes, you can do all the searching and replacing with a plugin, but you need to make sure it’s Multisite compatible so it will change the domains for your main sites as well as all your additional sites.

      Hope that helps!

      Cheers,

      Jenni

    Charles

    Hi, this looks like the best post I have found on this process.

    I have a “test” subdomain I have done all my development work on. I want to migrate that site to my main “live” domain, on the same server.
    I need to keep the “test” subdomain intact, as I will be adding more features for the client (membership and ecommerce). We will be adding sites to the network as we expand, as well.

    As I read through this post, it seems if I do everything that is in here, I will loose my test subdomain. Do I understand this correctly?

    How do I move the “test” to “live”, and keep the “test” intact?
    Right now on “live” there is a site running that I want “test” to replace.
    When I am finished, I need “live” to be the same as “test”. The “live” version will be the active site, while I continue to develop on the “test” site.

    Thanks, great post – right to the point.

      mpress

      Hi ,

      Thanks for this post. I t has helped a lot!

      @Charles,
      I did today a migration from an old website to a new one.
      First of all I have made an import from the database to the new website db.
      Second a copy of all wp files to the new website (using filezilla).
      Then I changed config.php and other info by the new website using the information from this post.

      Now I have an old website (test environment) and a new site that I will launch soon.

      Hope it helps!

      Jenni McKinnon

      Hey Charles,

      Glad you liked this post. :)

      @mpress is right about how to migrate your site (Thanks mpress!).

      This post is just about changing your domain name, but if you want detailed instructions on how you can move a site to replace an old one, check out these posts:

      1. http://premium.wpmudev.org/blog/guide-to-migrating-localhost-wordpress-to-live-site/

      2. http://premium.wpmudev.org/blog/migrating-wordpress-and-multisite/

      It sounds like your live site and test site are on the same server if I understand correctly, and if that’s the case, you wouldn’t need to change your name servers as described in the second post.

      To be honest, I just use the Cloner plugin, myself because it’s just so much easier and faster. In a couple clicks your test site can be copied to your live site, replacing your live site while still keeping the content on your test site. I also use the Multisite Privacy plugin to password protect the test site so regular passers-by can’t see your work in progress. It also helps protect your SEO ranking if your test site has duplicate info when compared to your live site.

      If you would like more info about these plugins, here are the links:

      Cloner plugin:
      http://premium.wpmudev.org/project/cloner/

      Multisite Privacy plugin: http://premium.wpmudev.org/project/sitewide-privacy-options-for-wordpress-mu/

      Hope that helps. Let me know if you have any more questions.

      Cheers,

      Jenni McKinnon

    Andrew

    Hello,
    Do you have any tips on doing such a move only for migrating the whole site to https?

    I followed your steps only changing instances of http to https and still get insecure content warnings.

    Thanks for the guide though, it super easy to follow!
    Best,
    Andrew

    Kathleen

    I followed the guide completly. There were some tables that I didn’t have.
    The move looks correct but my pages won’t work.
    It looks like the permalink hasn’t been changed.
    Any idea what went wrong?

    Best,

    Kathleen

      Kathleen

      Woops, there were a few more things I had to change, found it searching without the .com.

      But I now have to change the colours of the website again.

Comments are closed.