Multisite: From Subdomain to Subfolder

A few years ago we changed a multilingual blog into a WordPress Multisite network using MultilingualPress for the multilingual part. Today, with wanting to have SSL on all sites, this slowly grew into a nightmare.

So after checking all options, I realized everything would be so easy if we just could change the network from the domain based network (“subdomain” install) it was into a path based one (“subfolder” install).

When we first created the network, we used the subdomain install because it said right there in the WordPress codex that you should not use the subfolder approach if your website had been set up for longer than a month. It’s been a while and I never doubted this.

Beware of Conflicts with Permalinks

The only reason for this, however, seems to be that you might run into conflicts between page names and actual site names. Since we only had language appreviations for site names (de for German, en for English,…) I felt we would be safe to go.
(You’ll find all the information you need in the “Multisite Network Administration” section of the WordPress codex.)

And it actually was as easy as that:

Wait, do I really need to say, please back up your site BEFORE you go any further?

Done? Alright, let’s go.

Changing your Network Type

If you want to go from subdomain to subfolder, you first need to change

to read

Then you need to update your .htaccess file, this is the example one for SUBFOLDER install if you started your multisite with WordPress version 3.5 or higher:

(You’ll find all the code examples in the network section of the WordPress codex.)

Now you can go ahead and change the URLs of your blogs to resemble the new structure, for example:

en.example.com has to be changed to example.com/en

You can use a “search and replace” plugin to check if there are any old URLs left in the database (I like Better Search Replace or Search & Replace).

Now, all that’s left to do is to get a 301 redirect in place to redirect your regular visitors from your old structure to the new one.

And How About Multisite and Virtual Hosts?

If you are like me you are a bit nervous about this and want to try it in your local development environment first. We certainly do not hack live sites if there is any other option. 😉

Please beware: Multisite does NOT work on your local machine if your WordPress address is “localhost” or an IP like 127.0.0.1. The codex explains this within the Network Admin section.

Generally speaking you need to change the port your virtual machine uses to port 80, which will allow you to use “normal looking” domains, like e.g. “example.com”. Tools like MAMP etc. make it fairly easy to change this.

As soon as you got that set up you are good to go!

Leave a Reply

Your email address will not be published. Required fields are marked *