Using multiple Domains with WordPress MU

By default in WordPress MU, blogs can be username.yourdomain.com or yourdomain.com/username/. But what if you want select blogs to have their own domain? It’s actually easier than you think.

Overview:
– install a domain mapping plugin
– park a domain
– map a blog to a domain

First, get the WordPress MU Domain Mapping plugin. NOTE: this domain mapping plugin only works with subdomain installs.

You can download it from inside WordPress MU using the plugin installer, but it will have to be moved from the plugins folder. In WPMU, there is another plugin folder called mu-plugins. This is for mu-specific plugins that will be run all the time. Plugin in this folder do not need to be activated and they will not show up in the Plugins list in the admin area.

Place the domain-mapping.php file in the mu-plugins folder.

There’s another file included called sunrise.php. Place this in the wp-content folder.

The file gets run before most of WPMU and handles the domain requests. In order for it to be recognized, we now have to edit the wp-config.php file.

In your Cpanel, go to the File Manager, and find wp-config.php in the public_html folder. Click on the filename, and then click on the Edit File option on the right hand side.

Most of the way down the file, under the language options, will be a line that is commented out, meaning it won’t run.
//define( ‘SUNRISE’, ‘on’ );

The two slashes (//) at the beginning of the line are what we need to remove.
define( ‘SUNRISE’, ‘on’ );

Save your changes. If you get an error, it will be because this file is created by the server on install, so you may not have permissions. Just ask support to make this change for you.

Before we map our domain to a blog, let’s set up our second domain so it knows where to go.

Login to your domain registrar, and change domain2.com’s nameservers to the same nameservers as your WPMU account. It will be something like ns102.wpwebhost.com & ns103.wpwebhost.com.

Now login to your control panel for your WPMU web account. In the main cPanel menu, scroll down to the Domains box. Click the “park a domain” icon.

parking

In the box, type in domain2.com, where domain2 is the domain you want to map. It should come back with a success. If not, you may have to wait a few minutes for the nameserver change to catch up.

Finally, we are almost at the best part. Login to the backend of the blog that you want to change the domain of.

(Using Donncha’s plugin, if you map a domain from the admin area of the main blog, you will accidentally change the main blog’s domain. This menu option is also available to the admin of the blog, not just Site Admins.)

Look under the Tools menu for the Domain Mapping sub-menu. It’s pretty straightforward.

DomainMapping

First, fill in the IP address of your site. You, as a site admin, will only have to do this once. We don’t have to worry about the rest of the instructions, because when we parked our domain on top of our WPMU install, that took care of it.

Fill in the domain name (domain2.com) and save. The screen will refresh and show the domain name as active on this blog.

Since we are still on the subdomain, visit domain2.com to confirm that everything is working as it should. Now any attempts to visit the original subdomain will be redirected to domain2.com. You can continue these steps for each domain you would like mapped to a corresponding sub-blog.

About the Author