Because multisites have a more complicated configuration of their subsite URLs, you’ll need to run some specific SQL queries to update them. Use these example queries below to generate those SQL commands by swapping out the domains.
UPDATE wp_blogs
SET domain = REPLACE(domain, 'olddomain.com', 'newdomain.com')
WHERE domain LIKE '%olddomain.com%';
UPDATE wp_options
SET option_value = REPLACE(option_value, 'olddomain.com', 'newdomain.com')
WHERE option_value LIKE '%olddomain.com%' AND option_name = 'siteurl';
UPDATE wp_options
SET option_value = REPLACE(option_value, 'olddomain.com', 'newdomain.com')
WHERE option_value LIKE '%olddomain.com%' AND option_name = 'home';
UPDATE wp_site
SET domain = REPLACE(domain, 'olddomain.com', 'newdomain.com')
WHERE domain LIKE '%olddomain.com%';
UPDATE wp_sitemeta
SET meta_value = REPLACE(meta_value, 'olddomain.com', 'newdomain.com')
WHERE meta_value LIKE '%olddomain.com%';
UPDATE wp_2_options
SET option_value = REPLACE(option_value, 'olddomain.com', 'newdomain.com')
WHERE option_value LIKE '%olddomain.com%' AND option_name = 'siteurl';
UPDATE wp_2_options
SET option_value = REPLACE(option_value, 'olddomain.com', 'newdomain.com')
WHERE option_value LIKE '%olddomain.com%' AND option_name = 'home';
UPDATE wp_3_options
SET option_value = REPLACE(option_value, 'olddomain.com', 'newdomain.com')
WHERE option_value LIKE '%olddomain.com%' AND option_name = 'siteurl';
UPDATE wp_3_options
SET option_value = REPLACE(option_value, 'olddomain.com', 'newdomain.com')
WHERE option_value LIKE '%olddomain.com%' AND option_name = 'home';
In the example section of wp search-replace
there is also a bash script that may work as well.
# Bash script: Search/replace production to development url (multisite compatible)
#!/bin/bash
if $(wp --url=http://example.com core is-installed --network); then
wp search-replace --url=http://example.com 'http://example.com' 'http://example.test' --recurse-objects --network --skip-columns=guid --skip-tables=wp_users
else
wp search-replace 'http://example.com' 'http://example.test' --recurse-objects --skip-columns=guid --skip-tables=wp_users
fi
If you weren’t redirected here from our Help Doc and need more guidance on Multisites in Local, check out our guide below for further details!