Moving or migrating a WordPress Multisite can be frustating. If you don't know how to move it safely, your site can break along the way. Either the database, the settings, or both. Let me share you how to migrate WordPress Multisite safely without breaking anything.
[Last major update on 27 June 2021. In this version, I use the latest version of interconnectit's Search Replace DB script (v4.1.2). Along with that change, I also streamlined this tutorial and thus made it has fewer steps than the previous version. As a result, some comments are outdated as they pointed to certain step number in the past. If you are confused or need any help, please don't hesitate to leave new comment below or contact me.]
In this tutorial, I will explain how to move WordPress Multisite from live server to localhost with an example case:
- We will move WordPress Multisite from http://example.com to http://localhost/example.
- The live server is using cPanel and the localhost is running on XAMPP.
How to Migrate WordPress Multisite from Live Server to Localhost:
Step 1 - Download the WordPress files from live server
You can download it all via FTP. Or if you prefer to download it directly from cPanel, you can go to 'File Manager' in your cPanel. Navigate to public_html. Select all files, click 'Compress'. Download the compressed file. Don't forget to delete the compressed file from live server after you finish download it.
Step 2 - Download the database from live server
Go to cPanel's phpMyAdmin. Export the entire database of WordPress Multisite that we want to move.
Step 3 - Extract the downloaded WordPress files to localhost
Create new folder 'example' in localhost folder (\xampp\htdocs). Extract the compressed file that we have downloaded in Step 1 to the folder 'example'. Now we have the WordPress files inside the folder 'example' (\xampp\htdocs\example).
If you installed cache or security plugins on your live site, you may have to deactivate it on the localhost by renaming the folder's name to something else temporarily. For example, if you installed W3 Total Cache plugin, go to the plugin's folder (\xampp\htdocs\example\wp-content\plugins\w3-total-cache) and rename it to something else e.g. 'Xw3-total-cache'.
Step 4 - Create new database in the local phpMyAdmin
Visit http://localhost/phpmyadmin/. For this tutorial, I will name it 'exampledb'. Import the database that we have exported from live site in Step 2.
Step 5 - Edit the .htaccess
Open .htaccess in the root folder (\xampp\htdocs\example\). Edit RewriteBase into:
If there are redirect issues or you can't access your site on localhost at all, there might be additional codes added to .htaccess by your installed cache or security plugins. If that's the case, comment or remove those codes. Retain only the codes in between #BEGIN WordPress and #END WordPress.
Step 6 - Edit the wp-config.php
Open wp-config.php in the root folder. Change database information to:
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
/** MySQL hostname */
Also, edit these two lines to:
/* Multisite */
If your live site uses https, comment or remove any lines related to the https settings on the local site, for example:
Step 7 - Prepare to change all urls (download the Search Replace DB script)
DO NOT manually search and replace everything. WordPress database use data serialization. Any mistakes can make your site cannot work properly. You have to use tools or scripts to search and replace database. As recommended on WordPress, we will use Search and Replace Database script from interconnectit.com.
Step 8 - Extract the Search Replace DB script to root
Extract the whole folder to root. It will be \xampp\htdocs\example\Search-Replace-DB-4.1.2. This script is quite powerful and can be used to break your site. So, please remember to remove it once you finish using it.
Step 9 - Run the Search Replace DB script
Run the script by visiting http://localhost/example/Search-Replace-DB-4.1.2.
You will see that there are 5 main sections in this page, i.e. SearchReplace, Database Details, Which Tables?, Let's go, and DELETE.
The following steps (Step 10 - Step 14) will be about those sections in the script's page (http://localhost/example/Search-Replace-DB-4.1.2).
Step 10 - Input urls in the 'SearchReplace' section
Input 'http://example.com' in 'replace' field and 'http://localhost/example' in 'with' field.
If your live site also has https urls, you can click the '+ add more search terms' and input 'https://example.com' in the additional 'replace' field.
Step 11 - Add the database information in the 'Database Details' section
You only need to fill the database name and username. Input 'exampledb' in the 'database name' field and 'root' in the 'username' field. Click the 'Test connection' to make sure the script can connect to the database. If there is no issue, a green message of 'Success, You are connected' will show up.
Step 12 - Change the settings in the 'Which Tables?' section
Select 'all tables'. Input 'guid' in the 'columns to exclude (optional, comma separated)' field.
Step 13 - Search and replace urls
Go to the script's 'Let's go' section. Click 'Do a safe test run' to see if there would be any issues. If there are no issues that need your attention, you can proceed to click 'Search and Replace' button.
Step 14 - Delete the script
Now you can remove the Search Replace DB script from your root folder. You can click the 'delete me' button on the 'DELETE' section on the script's page. However, it will still leave the folder and some files. I prefer to remove it directly from \xampp\htdocs\example.
Step 15 - Change domain and path in wp_site table
Go to the 'exampledb' database (navigate from http://localhost/phpmyadmin/).
Then, click the wp_site table (or yourtableprefix_site). Change domain, from 'example.com' to 'localhost'. And path, from '/' to '/example/'.
Step 16 - Change domain and path in wp_blogs table
As in Step 15, you also have to change all of the domains and paths in wp_blogs table (or yourtableprefix_blogs).
Change domain, from 'example.com' to 'localhost'.
Change path from '/' to '/example/'. If you have second site named as '/site2/, you have to change the path to '/example/site2/'. Do the similar to all paths.
Step 17 - Final check
Try to visit the site in http://localhost/example and login to admin area from http://localhost/example/wp-login.php.
You should see it running smoothly without problem. 🙂
Is this tutorial helpful for you? Do you want to add something to make it better? or do you want to share your experience when moving WordPress Multisite?. Share it all in comment form below.
Can I use this tutorial to move WordPress multisite from localhost to live server?
Yes, you absolutely can. In fact, you can also follow the steps in this tutorial to migrate WordPress single site from localhost to live server or from live server to localhost too! I can say that because I also use this tutorial for those purposes 🙂
However, of course, there are things that you have to adjust for those situations. The main things you have to note are the database information and the urls or paths in your live server and localhost. Basically, you only need to switch those details between live server and localhost.
If you want to migrate WordPress single site, you can follow this tutorial step by step, but skip Step 15 and Step 16 as those two steps are exclusively for WordPress multisite.