Multisite Separate Domains With '.local'

I have a subdomain multisite that I’ve imported into Local and can access the Dashboard for, but the subsites are using separate domains that I also want to access as site.local. Using the multisite SQL command generator does work for the main domain, but obviously it doesn’t know about the separate domains, so I used this command in Adminer to replace the other domains in wp_blogs:

UPDATE `wp_blogs` SET `domain` = REGEXP_REPLACE(`domain`, '\\.com$', '.local')

I’m not sure what Sync MultiSite domains to host file uses as its source of domains, but even if all the entries in wp_blogs have a .local domain, /etc/hosts still has .com for every domain other than the primary. If I manually change a domain in the hosts file (e.g. to site1.local1), then go to https://site1.local, my browser prompts me with a security risk certificate page. Continuing to the site, however, redirects me to the live site (, not the local version. However, if I go to https://site1.local/some-page, I’m not redirected and I can access my locally hosted site.

Based on this topic and this topic, I tested setting one site to .local in the hosts file and added it to the server configuration. I don’t remember what I did after - either went to the site, reloaded Local, synced hosts, something - but the change managed to persist, and Local automatically sets that domain to .local in the hosts file (but doesn’t add it to route.X.local.conf).

Has anyone been able to set up a multisite with separate domains? I feel like I’m close, just missing one last step.

I got it! I ran the WP-CLI command wp search WORKING_SITE.local --network, and I found a couple of entries in wp_26_options::option_value column set to https://WORKING_SITE.local in the siteurl and home opetions (where 26 is the site’s blog_id, which you can find in wp_blogs for example). I then chose another non-working blog ID and checked its wp_X_options table, and found that its options were set to Changing them to .local and rerunning the Sync MultiSite domains to hosts file worked! I can access the site locally, and all page links go to ~.local/page.

(Side note: the redirection turned out to be from browser caching. In Firefox, I went to my history and clicked on the live site, then clicked Forget About This Site. I could then access the .local site without redirection.)

From what I can tell, here’s the process for transferring a live subsite multisite to Local (similar steps to WordPress Multisite with Local - Local):

  1. Download a backup of your multisite and its database.

  2. Create an empty multisite install on Local and configure the PHP/SQL versions appropriately.

  3. If you want to change the WordPress version, open the site shell through Local and run wp core update --version==X.Y.Z --force.

  4. Go to your empty site’s directory on your computer (~/Local Sites/multisite/app/public) and delete the wp-content/ folder. Replace it with the wp-content/ folder from your backup.

  5. Drop the local database tables that were generated while creating the empty multisite. (Either from the terminal in ~/public/ with wp db clean, or using Adminer.)

  6. Import the database from your backup. This can be found at ~/wp-content/mysql.sql (Again, either through the terminal with wp db import "PATH" or through Adminer.)

  7. Change your site’s main domain if necessary (not sure if changing in Local is enough or if is needed, my steps from last week say to use the website first and then change in Local as well. I had set up the multisite with, then used the website to generate the SQL commands (run in Adminer) for changing the database from .com to .local. After that I changed Local’s domain from .com to .local. YMMV.).

  8. In Adminer, run the SQL command UPDATE `wp_blogs` SET `domain` = REGEXP_REPLACE(`domain`, '\\.com$', '.local') to update the domains in wp_blogs. This changes the entries in the multisite’s Dashboard > Sites to say .local.

  9. For each subsite, locate its blog ID (for example, under blog_id in the wp_blogs table, or in the Sites Dashboard by hovering over Edit on a site and looking at the link). Go to the wp_ID_options table for the given ID (i.e. if the ID is 5, go to wp_5_options) and set the siteurl and home options to .local.

  10. In Local, click on Sync MultiSite domains to hosts file. You’ll likely be prompted to give Local permission to edit your hosts file. Afterwards, you can access your subsite locally!

A couple of caveats:

  • I’ve not explored automating step 9 yet (that’s next for me). There’s also wp search-replace --network, but I don’t know if that would change too much and cause unforeseen problems. Still need to test.

  • I’ve also not been able to get SSL to work for any of the sites, whether it’s the main domain or any of the subsites. Perhaps Generate SSL for multiple local domains within a multisite (domain or subdomain) - #2 by ben.turner?

  • I had an issue where I could access the Dashboard for my main domain, but not a subsite. At first, the issue came from a WP Engine plugin - removing the wp-content/mu-plugins/ folder fixed the error message preventing me from logging in (setting WP_DEBUG to false in wp-config.php also helped). However, when I went to login, I got the error Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress. preventing me from logging in. In wp-config.php, adding define( 'COOKIE_DOMAIN', false ); fixed it and let me log in. Don’t know how that would affect the live site if pushed to production, though.

Happy editing!

1 Like

Hi there @tommy.m!

Thank you for bringing this to the Local Community & so thoroughly documenting the fix.

Happy to hear it’s all working well for you now! :tada:

I’m going to mark this as solved,

:woman_technologist:t3: Sam

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.