Converting WordPress Multisite to a single site


creative commons licensed ( BY-NC-SA ) flickr photo shared by Packfill
A few years ago, in a fit of ambition and desire to host all the things, I set up my school blog as a wordpress multisite with four separate blogs, three of which had separate subdomains: one for my face to face classes, one each for my online classes, and one for Pedagogy First! (oh yeah, and there’s this personal blog too).

Now, it’s too much. I don’t want to update five blogs. Hell, I’m not even really keeping up with one. Additionally, for some inscrutable algorithmic reason, Google responds to searches by my students for my blog with links to my online class blogs, which have lain dormant for years, rather than to my main school blog.

Enough. One school blog and one personal blog are enough. So how do you go back? (First obviously, you back up, and then you go back. You’ve been warned.)

This wpmudev blog post walked me through it, but I’ll post instructions here as well for  future reference.

I used file manager in cPanel to edit my wp-config.php file (first I copied it to wp-config.old in case I screwed up). I then deleted the following lines:

define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );
$base = '/wordpress/';
define( 'DOMAIN_CURRENT_SITE', 'localhost' );
define( 'PATH_CURRENT_SITE', '/wordpress/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

The wpmudev post called for editing my .htacess file to match the following, but mine was substantially the same, so I left it alone:

RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
RewriteRule . index.php [L]

Next, I edited my wp-config file and dropped the following tables from my database. I’m pretty sure there’s room for disaster in all of the above steps. Backup.

wp_blogs
wp_blog_versions
wp_registration_log
wp_signups
wp_site
wp_sitemeta

At this point, the other blogs were gone, and I had a single blog. (And by gone, I mean GONE–this doesn’t merge all the subdomains–it just deletes everything but the main blog.)

One thing left to fix: redirecting the subdomains. I had to create a wildcard subdomain, so when someone goes to [subdomain].learningbusiness.net, it still showed the subdomain in the address bar. In cPanel, I went to the subdomain panel and added an explicit subdomain for each of my former subdomains and then I went to the redirect page in cPanel and added a redirect to my main URL so that if someone types the old subdomain, it redirects to the main domain and keeps the URL consistent. PedagogyFirst posts, on the other hand, I redirected to the EdTech category here on my personal blog where I imported all of my old posts. I’m sure I’ve broken a few links on other people’s posts (sorry!), but my posts are still there to be found with a little digging.

Comments are closed.