Previously I’d only ever posted this in my ebook, WordPress Multisite 110.
What people mean by this is the site they originally set to be seen at domain.com is no longer the one they want to use, but the one at (say) domain.com/temp or temp.domain.com. If this is what you’re wanting to due, it’s not impossible, but it is annoying and a little tricky. If you’re using the trick to give WP it’s own directory, these are not the directions you’re looking for. I haven’t written those out yet.
First you have to go to Network Dashboard > Sites and edit the site you want to be the main site.
This you want to to look like this:
Make certain you leave ‘Update siteurl and home as well’ checked! If you forget that, you’ll be sad. You no longer need to check the box (it’s gone in newer versions of WP), but if you DO have it, check it.
Now you’d think you go to edit the main site and change it, but you can’t.
By default, the main site is not editable. This makes sense when you think about how messy this might be, so in order to edit it you have to go to your wp-config.php file and look for this line:
Change it to the site ID you want to use as your main site. In this example, I want site #2, aka, two, to become my main site.
Save the file and then you have to go back to your Sites and edit the old main site.
Give its path a new name and press save, making sure you keep that checkbox checked if it’s there.
In this example, I’ve picked a new URL for my formerly main site becuase I don’t want any conflicts, but there’s nothing stopping me from picking ‘two’ again and just totally swapping things.
The last step is to change your post content. Using a plugin like Velvet Blues Update URLs, you will need to search each site separately and replace the URLs. If you have wp-cli, you can do that too like this:
wp search-replace 'example.com' 'example.com/new' wp_posts wp_postmeta --dry-run wp search-replace 'example.com/two' 'example.com' wp_2_posts wp_2_postmeta --dry-run
If those look good, rerun without dry run and call it a day!
An interesting quirk is that you may need to edit the Fileupload URL if you’re using blogs.dir for your images. I noticed that on one site it was set to
http://example/two/files which clearly is wrong. To fix that, go to Network Admin, click on Sites, and click on edit for the site. From there, click on the dangerous “Settings” tab and look for “Fileupload URL” and edit as needed to match things.
Cool tricks like this can be found in WordPress Multisite 110.