Changing Your Domain Name In Multisite

It's three steps, it takes five minutes, and it's not impossible at all. Also if you're having a Multisite 'redirect loop' after upgrading to 3.9 read the extra step at the end.

Even I hate moving Multisite if I have to change folders (like from to But if you told me “Mika, I need to change my domain from to!” 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

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 to (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', '');

Change the value to 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


    • @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 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 to, 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 – NOT – 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.

Comments are closed.

%d bloggers like this: