When you install WordPress Mu, it warns you:
Please choose whether you would like blogs for the WordPress µ install to use sub-domains or sub-directories. You can not change this later. We recommend sub-domains.
It’s true there’s no documented way to change this setting, and the current advice is to reinstall (!), but I aim to change that. Instead of reinstalling plugins, reconfiguring plugins, and then powering through the nightmare that is WordPress export->import, I resolved to find whatever setting was buried in WordPress and do it manually. And lucky for me, it turned out to be surprisingly easy.
I’d originally set up welcome.totheinter.net to use subdomains for my Mu installation, but I decided recently that subdirectories would make much more sense. After all, I’m using Mu to power my one site, and subdomains feel like lots of separate sites. In retrospect, installing Mu as subdomains was the wrong decision.
So during some downtime in the ‘ole ICU last month, I decided to see if this weren’t, in fact, a solvable problem, and it turns out it’s a pretty easy fix.
Step 1: Backup your database and config file
I’ve always subscribed to the “protect my data from my #1 enemy: me!” mentality.
Step 2: change each blog’s URL
In the admin console, go to the blogs page.
For each blog, click the edit link to edit that blog’s details. You’ll want to edit the following fields to all be consistent with the new location you want each blog:
- Fileupload Url
For instance, I used to have one of my blogs set up at http://page2.welcome.totheinter.net/ but I moved it to http://welcome.totheinter.net/notes/. To do that, I changed the Domain from “page2.welcome.totheinter.net” to just “welcome.totheinter.net” and the Siteurl from just “/” to “/notes/”. I similarly updated all of the other fields for that blog.
Step 3: Update wp-config.php
There’s one line in the wordpress config file that tells Mu to use subdomains instead of subdirectories. Change:
Step 4: Update httpd.conf
If you’ve set up Mu to use subdomains, then you need to undo your wildcard subdomain setup in your httpd.conf. Matt Mullenweg has a great post explaining how to create the wildcard domain in the conf, so if you’re trying to go from subdirectories to subdomains it’s a great read.
If you’re going from subdomains to subdirectories (like me), just remove the wildcard domain from your httpd.conf and restart apache.
Make sure (of course!) that you still have a virtual host defined for your actual site’s domain. It should look something like:
<VirtualHost 184.108.40.206:80> ServerName welcome.totheinter.net ServerAlias www.welcome.totheinter.net DocumentRoot /home/internet/public_html/welcome ServerAdmin email@example.com UseCanonicalName Off </VirtualHost>
Optional Step 5: Redirect from old subdomain to new subfolder
Good SEO tells you to redirect a URL you move to it’s new location with a 301 redirect header. To do that, I first setup a subdomain in CPanel that matched the blog’s old subdomain location. Then I just edited the .htaccess file for that subdomain to point all incoming traffic to the new URL. The .htaccess for page2.welcome.totheinter.net is now:
RewriteEngine On RewriteBase / RewriteRule ^(.*) http://welcome.totheinter.net/notes/$1 [R=301,QSA,L]
It turns out resetting WordPress Mu to use subdirectories instead of subdomains isn’t all that bad! And I’d imagine that moving from subdirectories to subdomains requires near identical steps.
Hope this helps you out – it’s certainly saved me from a reinstall hell!