I had a situation where I needed to create a WordPress Multisite network of sites with each site having completely unique domain names. I found everything I needed by Googling around and I got it to work, but I wanted to document it for later use because there are some “gotchas”. Here’s the procedure.
SPECIAL NOTE: Astute reader Mara has pointed out to me that WordPress has made domain mapping a native feature since version 4.5. I intend to give it a try next time I need to do this. The procedure below will still work though.
WordPress Multisite is great for creating a network of sites administered through a single master admin and sharing a set of themes and plugins. The sites can have different themes or share themes. You have two choices on how the sites are mapped: by sub-domain or by sub-directory.
Sub-directory would mean your network of sites look something like this:
And so forth. Sub-domain means your sites would look something like this:
Note in the above two sets of examples, the second level domain name is always the same: “animals”.
My goal was to have a network of sites that looked like this, with each site having a totally unique second-level domain name:
All of these would be on the same single WordPress Multisite install. Can it be done? Yes!
Of course, I am assuming that you have ownership of the domain names here (i.e., you have purchased them). You should go ahead and point them all at the directory where you have installed WordPress Multisite.
The process for doing this is different for every hosting provider. On GoDaddy, go to My Products -> Domains and click on Manage. Click on the domain you want to use to get to the Domain Details page. Open the DNS Zone File tab and change the @ record to point to your server’s IP address (you can get that from the hosting section of the GoDaddy back-end). Your domain name is now pointed at your server.
Next, go to Hosting -> Manage to get to the cPanel. Click on “Addon Domains” (this might be named slightly differently on different versions of cPanel, even within GoDaddy).
In the “Create an Addon Domain” form, type in your domain name, let the subdomain auto-populate, and choose your Multisite parent’s directory (do not create a new directory for this domain!)
Basically you need to point all of your domain names at the directory with the WordPress Multisite install.
Here’s how to do it if you are self-hosting on Amazon EC2.
Installing WordPress Multisite
I had heard that you can set up WordPress Multisite by “adding one line to wp-config.php”. Well, it’s not that simple, but it’s not too bad either.
First, install regular WordPress in the root of your master directory (to which your master domain name points). Note that the Domain Mapping plugin below might not work if you install WordPress in a subdirectory, so install it in the root.
To convert this site to Multisite, you indeed start by adding a single define statement to the wp-config.php file, but that is just the beginning. I used these instructions from WPMU to set up my Multisite install (scroll down to the section titled “Activating Multisite on a Fresh WordPress Installation”).
Note, I highly recommend configuring Multisite from a virgin WordPress install, not an existing site. When I tried to do it from an existing site, I got the dreaded “Database not found” error (the actual error has nothing to do with finding the database though).
Somewhere around the middle of the process, you’ll have to choose between using subdirectories or subdomains for your Multisite network. I didn’t know which to pick at first. For our purposes, choose subdirectories. I read here, that it doesn’t really matter in our case, but subdirectories are easier to work with and don’t require tinkering with your hosting or DNS. Plus, you can always map subdirectories using the Domain Mapping plugin below.
The instructions from WPMU are pretty good. Other than deciding between subdomains vs. subdirectories, I didn’t have any problems.
Creating the Child Sites
Once you complete the install, go ahead and create your sites by going into My Sites -> Network Admin -> Sites. On that page, click “Add New” to add your sites. You can worry about setting the themes and other stuff later. Just get them created for now.
Now, you should have a network of sites on subdomains of your main site.
To get each site to be on a separate domain, start by installing the WordPress MU Domain Mapping plugin from the repository. Follow the installation instructions carefully. This installation process for this plugin is more involved than most other WordPress plugins. You’ll need FTP access to your server in order to modify your wp-config.php file and move the sunrise.php file to /wp-content.
Note, when copying the “sunrise” line of code into your wp-config.php file, make sure you use the correct kind of single quotes. If you just copy and paste the line from the plugin’s website, you’ll have the wrong kind of single quotes. If you’re unsure, use an editor to overwrite the single quotes with the right ones (‘) from your keyboard.
After you’ve followed the installation instructions, you can start creating subdomains. You’ll need to first create the child multisite installs. When you do, note the ID number of each install.
Then, go to Settings -> Domains and enter the site ID and desired domain name (without the “http://”) of each child site:
After I did this, I navigated to one of my unique domain names and it redirected to one of the WordPress Multisite pages! That was good, but not exactly what I wanted. I wanted the unique domain name to mask the WP Multisite subdirectory.
After some research, I found the setting that accomplished that. In the WordPress admin, go to Settings -> Domains and check the “primary” box. That will make your domain name mask the WP Multisite subdirectory. That should do it!
So, this is pretty cool. You can have a network of sites all managed from a single WP Multisite install, and each with a unique domain name. I am by no means an expert on WP multisite, so let me know if you have any comments or better ways to do things! Hope this was helpful. – Brian