Even I hate moving Multisite if I have to change folders (like from domain.com/wordpress to domain.com). But if you told me “Mika, I need to change my domain from cocobanana.com to cocoabanana.com!” I’d say “Hold my beer for five minutes.”

No. 2 pencilsI will note: If this process freaks you out, remember to never make changes like this without a backup. If it’s still super spooky, you may not be ready for Multisite yet. I would consider this to be a good litmus test, though, for a wanna-be-multisite-master. You’re going to need to be able to do these things to get there.

Step 1: Search and Replace

This is the easiest one. If you have WP-CLI it’s super easy.

wp search-replace http://cocobanana.com http://cocoabanana.com

Don’t have WP-CLI? Okay, grab Interconnectit’s Search/Replace DB Tool and use that.

This will take care of 99.999999% of your site. It’s imperative you remember to use this tool! If you don’t use a tool that searches and replaces with consideration to data serialization, you will cry and reset all your themes and widgets. Manually. See? Told ya you’d cry!

Step 2: Edit the Database

Go into the database. Look at the wp_site table. Change the domain field from cocobanana.com to cocoabanana.com (seriously, that was it!).

Then look at wp_blogs and change those domains similarly as needed.

Step 3: Edit wp-config.php

Open the file and look for this:

define('DOMAIN_CURRENT_SITE', 'cocobanana.com');

Change the value to cocoabanana.com and save it.

Step 4: .htaccess and plugins

I lied. There’s another step. Make sure you weren’t super smart earlier. Like if you used some rules to block hotlinking, make sure the new domain is added in there. Also make sure your plugins aren’t calling your domain in some weird way (though that search and replace should have fixed that too).

Also if, like me, you hate www’s in your URLs, you’ll want to put this in your .htaccess to force everyone around. It also has the benefit of making sure the weird redirect of www being treated as a subdomain stops happening on Multisite. By the way, I still strongly encourage you to NOT use www in your Multisites, it’s a pain in the ass and you can educate people as to why no one has to have www anymore. Also WordPress itself has always suggested you NOT use it when activating Multisite. Do you know better than WordPress? No? Okay then, don’t use www.

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /
	RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
	RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Now can I have that beer back?

Beer and a cup

Reader Interactions


  1. Domain name of primary install?
    Isn’t that just a fix in the wp-config.php?!

    • @Lars Mielke: Not on Multisite. If you actually look at the wp_site and wp_blogs tables, you can see exactly why.

    • @Ipstenu (Mika Epstein):
      Okay, let it be.
      But why going manually into wp_site and other tables, when IC’s search and replace script can do this for you?

    • @Lars Mielke: tl;dr because it’s safer.

      Because of intelligent search and replacing and understanding the daftness of the universe πŸ™‚

      Notice how I said to search for wp search-replace http://cocobanana.com http://cocoabanana.com and NOT the non-http versions? Or WORSE not cocobanana/cocoabanana ?

      The odds of you having an image with your domain name in it, or a reference to it, means that a blanket search/replace for just the domain like that would have unexpected consequences.

      Far better to make sure you ONLY edit the http links (which will include links, images, and scripts), but NOT any posts where you talk about your domain. Well. Fewer posts. When I moved this site from tech.ipstenu.org to halfelf.org, I had to make sure I didn’t wipe out the post where I talked about my search/replace πŸ™‚

      The two tables I mentioned (since you may not have looked) contain the domain as domain.com – NOT http://domain.com – so you have to change them separately.

      That said. I still feel strongly that this small measure of editing is an imperative skill for a Multisite Admin to have under their belt.

%d bloggers like this: