How to Set Up WordPress Multisite Subdomains and Domain Mapping in cPanel


There are some pretty good tutorials explaining how to set up WordPress Multisite, and most of them are very similar. The first time I set up my Multisite install using cPanel, though, I ran into some challenges that were a bit frustrating. In this article I’m going to walk you through a cPanel WordPress Multisite installation, and try to help you avoid some of the pitfalls I ran into.

 

A Couple of Quick Notes

  • It is possible to set up a Multisite installation on a secondary domain in your account (meaning a domain that’s not your registered primary domain in cPanel). However, if you’re planning on  using the Multisite Domain Mapping Plugin (so that each subdomain looks like its own site), you’ll face some redirect problems. I never could get it to work – if you have, please tell me all your secrets in the comments. 🙂
  • This tutorial is specific to using subdomains (e.g. subdomain.maindomain.com, as opposed to subfolders, such as maindomain.com/subdomain). Discussing the pros and cons of each is outside the scope of this article.
  • I’m assuming you’re using a shared hosting service.
  • I’m assuming you have access to all of your files, either through cPanel’s file manager or via FTP.

 

Step 1 – Installing WordPress Multisite

If you haven’t already read through the WordPress Multisite documentation, then you may not be prepared for the next steps. Start at the WordPress codex. This will have all of the important steps to get you started. If you’re like me and just want to get to the point, then here’s the short version for installing WordPress Multisite:

  1. In your wp-config.php file (ABOVE the line that says /* That’s all, stop editing! Happy blogging. */), add this:

    /* Multisite */

    define( ‘WP_ALLOW_MULTISITE’, true );

  2. Refresh your wp-admin page.
  3. Under Tools, you’ll have a new option called “Network Setup”. Click this.
  4. Fill in the fields (selecting Sub-domains as the install type), and click “Install.”
  5. The next page will have some code to add to your wp-config.php file and your .htaccess file.
    • wp-config.php – I would recommend you rename your original file to wp-config.php.bak and save it to your local computer [thanks to Thomas Scholz for the addition…servers often scan for .bak files, so a local copy is preferred], then copy all of the contents of this file into a new file named wp-config.php (this lets you revert back to your original file if you ever need it). Add the lines that were instructed on the WordPress Multisite installation page, ABOVE the lines that tell you to stop editing, and, for convenience, below the /* Multisite */ line we added a few minutes ago. For subdomains, make sure that you have define( ‘SUBDOMAIN_INSTALL’, true ); (instead of false).
    • .htaccess – Again, I would rename the original file .htaccess.bak and save it locally, then copy everything into a new file named .htaccess (in case your WordPress Multisite installation goes sideways, you can always revert back to your original file). Between where it says “#BEGIN WordPress” and “#END WordPress”, remove the existing code and paste in the new code from your WordPress Multisite installation instructions in your admin panel.
  6. Log out of your WordPress admin area, then back in.
  7. In your WordPress admin bar, there should be a new setting called “My Sites” with a “Network Admin” option. That’s it – you’re all set up with WordPress Multisite.

 

Step 2 – Creating a New Site

This is fairly straight forward, but for convenience I’ll include the steps in short form, like above.

  1. Once logged into your WordPress Multisite Network, go to the admin bar up top and navigate to My Sites > Network Admin > Sites.
  2. Click the “Add New” button at the top of the page.
  3. Complete the fields. Note that whatever you put in as the Site Address will be the subdomain for your site. For domain mapping, it’ll make things a lot easier if this matches the stand-alone domain you’re going to use. In other words, if you own the domain “myawesomedomain.com”, then you’ll want to use “myawesomedomain” for the Site Address (which will make the new site’s URL “myawesomedomain.maindomain.com”, and we’ll map the standalone domain to this subdomain…confused? Stay with me, you’ll see in a bit).

Step 3 – Preparing cPanel for WordPress Multisite Domain Mapping

This is actually the part that I found to be the least documented online, and the most “fuzzy” and confusing of all the instructions for WordPress Multisite installations using subdomains and domain mapping. Here’s what you need to do:

  1. Buy your domain with your host or whatever registrar you want.
  2. Add the domain to cPanel as a PARKED domain (this is very important!). If you purchase your domain through a registrar that is not your host, I find that the easiest way to add a domain to cPanel is to point your nameservers to the host’s name servers. Just Google it – it’s pretty easy.
    Quick explanation of what’s going on, if you want to understand better (if not, just keep reading). When you add a domain to cPanel as an Add-on domain, it actually creates a new folder in your public_html folder with the same name as the domain you’re adding. So if you’re adding “subdomain.com”, it’ll create a new folder in /public_html/subdomain/ with a bunch of files, like a default landing page, default 404 error page, etc. cPanel also automatically creates a subdomain for you, so that if you navigate to subdomain.maindomain.com, it’ll actually pull the default files from the /public_html/subdomain/ folder. This complicates things for your WordPress Multisite installation, which is trying to grab this exact url for your new site. This is what we like to call a problem.
  3. Next you’ll need to set up wildcard (*) subdomains. In your cPanel home page, go to Domain Management and select Subdomains.cPanel Subdomains when installing WordPress Multisite
  4. On the next screen, under “Create a Subdomain”, you’ll just want to enter an asterisk as the subdomain. The asterisk is the wildcard. It should look something like this: cPanel Wildcard Subdomains when installing WordPress Multisite
    One quick note: On some hosts, when creating a new Subdomain, entering the asterisk will trigger an auto-fill value after public_html with “wildcard”. If this happens, make sure you delete this. Otherwise, the Document Root folder will actually be /public_html/wildcard and it won’t work right.
    One other quick note: If, after this whole tutorial, WordPress Multisite Domain Mapping still isn’t working for you, then verify the following:

    • The domain you added is Parked (not Add-on).
    • You’ve added the wildcard/asterisk as a subdomain, and the Document Root is only /public_html (NOT /public_html/wildcard).
    • There are no subdomains in cPanel that match the Parked domain you’re trying to map…in other words, go to the Subdomain area of cPanel (where you added the wildcard) and look for subdomains with a matching name. If you see any, delete them. Look for both “subdomain” and “www.subdomain”, as cPanel will typically add both when creating a new Add-on domain.
    • There are no subfolders in your /public_html folder that correspond with the domain your adding (i.e. /public_html/subfolder/). If it exists, delete or rename it.

    If you’ve changed anything here, then give the information some time to propagate (a day or two at most). If that fails, then contact your host and ask for help.

 

Step 4 – Mapping Subdomains

Now that we have cPanel out of the way, mapping subdomains should be pretty easy as well.

  1. Install the WordPress MU Domain Mapping plugin, then Network activate it.
  2. In your WordPress Multisite Network Dashboard, go to Settings > Domain Mapping.
  3. Enter your Server’s IP address in the Server IP Address field. In cPanel, you can find this on your home page on the very left (there’s a sort of floating widget with your server’s data on it) and select the Domain Options you want and click Save. For details on what each of the Domain Options mean, Google the information. If you just want something easy, I checked items 1, 2, and 4, and I’m pretty happy with those selections.
  4. In your Network Dashboard, go to Settings > Domains. There are 2 fields to enter: Site ID and Domain. The Site ID is the actual database ID of the site you created. You can find this by going to My Sites > Network Admin > Sites (from the admin bar) and clicking on the site you want to map. The URL of the page that opens contains the site ID – it should end with something like “site-info.php?id=xx”, where “xx” is your site ID. Once you have this, go back to your Domain mapping page, and enter the domain name you want in the Domain field (e.g. “subdomain.com”). Check the “Primary” box, and click save. (Note: Since you can map multiple domains to a single WordPress Multisite Site, WordPress needs to know which of these to actually display in the address bar when a user visits. The domain displayed is the “Primary” domain mapped.)

 

That’s it! Your WordPress Multisite Domain Mapping should be up and running. Once you’ve completed these steps, you should be able to enter your domain in your browser and your newly created site will show up.

If it’s still not working, read over the cPanel instructions one more time for good measure. Otherwise, contact your host or drop me a line in the comments below and I’ll do what I can to help. Good luck!


Leave a Reply

Your email address will not be published. Required fields are marked *