This actually isn’t hard to do, but it can be tricky to complete if you don’t remember what you started with.
To start with, let’s say I have a multisite with subdomains: ipstenu.loc. I’ve added in two subsites, foo.ipstenu.loc and bar.ipstenu.loc. But then I decide I really wanted to have ipstenu.loc/bar and ipstenu.loc/foo instead.
The easy part is first. I know my wp-config.php
has this:
define('WP_ALLOW_MULTISITE', true); define('MULTISITE', true); define('SUBDOMAIN_INSTALL', true); $base = '/'; define('DOMAIN_CURRENT_SITE', 'ipstenu.loc'); define('PATH_CURRENT_SITE', '/'); define('SITE_ID_CURRENT_SITE', 1); define('BLOG_ID_CURRENT_SITE',1);
All I have to change is the one line define('SUBDOMAIN_INSTALL', true);
to define('SUBDOMAIN_INSTALL', false);
and now I’m using sub-folders!
But that means that foo.ipstenu.loc isn’t really valid. Amusingly, it doesn’t break anything at first, so the still will work. But once I change the .htaccess, things will get hinky, so I’m going to do the ‘hard’ part.
Go in to Network Admin -> Sites and Edit each site that uses a subdomain and you’ll see this:
Looks familiar, right? I’m going to change foo.ipstenu.org
to ipstenu.org
and the line with /
becomes /foo/
:
As soon as I hit save, the site is ‘moved.’ Great! Do this for all my sites and .. wait. Now they look all ugly!
That’s because I have to edit the .htaccess
. Go to Network Admin -> Settings -> Network Setup, and copy the .htaccess
from there, replace, and now it works too.
The one last step is re-saving the permalinks in your main site, and remembering your links are about to break. What’s that now? Oh, yes, you see ipstenu.loc now gets /blog/ shoved in for any posts, so ipstenu.org/2012/postname became ipstenu.loc/blog/2012/postname. The catch here is that if you don’t resave the permalinks, they will continue to work until you do. Once you hit ‘save’ on permalinks, blog jumps in, and WordPress cheerfully redirects people for you, so you lose nothing.
And now you know!
Comments
7 responses to “Switching Network Types”
You do need to replace all entries which are hard coded in posts and other places in the database.
Like with the search and replace script, like this one: http://interconnectit.com/124/search-and-replace-for-wordpress-databases/
Yes and no.
Posts yes (obviously internal posts) but the funny thing is just changing it from edit sites will do the DB stuff for you in this case. Or rather enough of it that I didn’t have to do anything else. It’s possible my sample was too small when I tested it, but site design/widgets etc stayed the same.
So when you save the path WP will search replace the urls in the post content?
No, I said you’re right, you need to replace post content, but that was it. That search/replace tool wasn’t needed for the whole db.
So this Will replace the url in wp_blogs and wp_options but all content related entries (post content, widgets) won’t be replaced.
It changed everything in wp_blogs. (wp_options would include widgets you know)
That’s true, but some widgets use serialised like text widgets. I doubt that gets changed.
But its nice to know this.