Changing WordPress Mu from Subdomains to Subdirectories

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.

Blogs section

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:

  • Domain
  • Path
  • Siteurl
  • Home
  • 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:

define(‘VHOST’, ‘yes’);

to:

define(‘VHOST’, ‘no’);

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 207.58.152.45:80>
ServerName welcome.totheinter.net
ServerAlias http://www.welcome.totheinter.net
DocumentRoot /home/internet/public_html/welcome
ServerAdmin webmaster@welcome.totheinter.net
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]

Conclusion

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! :)

Explore posts in the same categories: install, Tips

2 Komentar pada “Changing WordPress Mu from Subdomains to Subdirectories”


  1. Hello everyone, it’s my first go to see at this site, and post is truly fruitful designed for me, keep up posting such posts.


Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s


%d blogger menyukai ini: