Using cPanel and Subdomains for WordPress Network Sites

Map Your WordPress Site to a Subdomain Using cPanel Tools

Wordpress logo
Wordpress Foundation

Setting up your WordPress network to map subdomains to your new sites can be tricky. With many web hosts, you can simply add the subdomain to your DNS records, as per the usual instructions for mapping subdomains to WordPress network sites.

But if you use cPanel, editing the DNS records may not work. In this article, learn the special instructions for mapping a subdomain to your WordPress network site using cPanel.

Version: WordPress 3.x

Let's say you have three sites on a WordPress network, like this:

- example.com/flopsy/
- example.com/mopsy/
- example.com/cottontail/

When you map them to subdomains, they'll look like this:

- flopsy.example.com
- mopsy.example.com
- cottontail.example.com

Begin With the Usual Instructions

The first step is to make sure you have tried the usual method for setting up subdomains. This includes setting up the
WordPress MU Domain Mapping plugin.

Once the plugin is installed and working, the usual next step is to edit the DNS records and add the subdomains. However, when I tried this on my cPanel host, I ran into trouble.

On cPanel, Editing DNS Records May Not work

The cPanel host seemed to intercept my attempt to set up a separate subdomain. The subdomain site (like flopsy.example.com) would land me on some weird statistics page for the host account.

Even though cPanel had let me edit the DNS records, this configuration simply did not work on this host.

Instead, the solution was to use the cPanel menu option to add a subdomain.

Use cPanel's "Add a Subdomain"

With this option, you do not point the subdomain to an IP address. Instead, you create a subdomain for a particular domain. You point this subdomain to the subfolder within your cPanel installation where you installed the original WordPress site, the site that you later transformed into a network.

Confused? I was too. Let's walk through it.

Subfolders, Real and Imagined

Let's say that, when we first installed WordPress, cPanel asked us which subdirectory (subfolder) to install it in, and we typed network. If we looked on the filesystem, we would see:

public_html/network/

This folder has the code for the WordPress site. If we browse to example.com, we'll see this site.

Once we had our WordPress site, we went through the arcane magic of turning example.com into a WordPress network.

Then, we set up a second site on this WordPress network. When WordPress (not cPanel, we're in WordPress now) asked us for a subfolder, we typed flopsy.

However (this is really important), we did not just create this subfolder on the file system:

public_html/flopsy/ (DOES NOT EXIST)

When WordPress asks for a "subfolder" it's really asking for a label for this website. The original site, public_html/network/, is a real subfolder on the filesystem, but flopsy is not. When WordPress gets the URL example.com/flopsy/, it will know to route the visitor to the "flopsy" site.

(But where do the files for the different sites actually get stored, you ask? In a series of numbered directories in public_html/network/wp-content/blogs.dir/.

You'll see blogs.dir/2/files/, blogs.dir/3/files/, etc.)

Add a Subdomain That Points to the Network Subfolder

Now let's go back to adding the flopsy subdomain in cPanel. Because cPanel asks you for a subfolder, it would be a very easy mistake to enter public_html/flopsy/. But that subfolder does not really exist.

Instead, you need to enter public_html/network/, the directory for the WordPress installation. You'll enter the same subfolder for mopsy, cottontail, and any other subdomain you add. They all point to the same public_html/network/, because they all need to go to the same single WordPress network.

WordPress will take care of serving up the correct site, based on the URL.

Once you know how this works, the cPanel method of adding a subdomain may actually be slightly easier than the usual method of editing DNS records. You'll soon be adding new WordPress network sites with reckless abandon.