WordPress is an astonishing piece of software. It runs 16.7% of the worlds highest trafficked sites, has a plugin repository with over 22,000 plugins, and is widely considered the number one blogging platform. It’s easily adaptable into a full CMS, which is precisely why we love using it and have our own multisite network setup here.
By adding in WordPress multisite domain mapping, we’re able to fully leverage the power of WordPress for our clients and allow them the flexibility of maintaining their own domain name.
What makes multiple domains difficult to use with one WordPress code base is the disconnect between the physical file system structure and the way WordPress creates permalinks. On a non-WordPress website, you could have the path of http://mysite.com/subfolder/ and this would be a physical subfolder location that you could point a domain to in your registrar’s admin panel, but in WordPress that location would be “virtual” (read more about WordPress permalinks here).
So, how do you resolve this issue? You could hire us to do it (*cough* please do! *cough*) or there’s a couple of alternatives. This tutorial focuses on the WordPress MU Domain Mapping Plugin written by Donncha O Caoimh.
We prefer tinkering around with things ourselves and the plugin is free. However, if you’re not into the nuts-n-bolts approach, there’s a service called WebSynthesis that integrates WordPress hosting and domain mapping functionality (props to Ron and Andrea Rennick of Copyblogger Media)!
Let’s get started!
What We’re Going To Accomplish
- Setup a WordPress Multisite Network
- Install and configure the WordPress MU Domain Mapping Plugin
- Create an additional site within your network
- Configure settings with your registrar/hosting provider
- Assign a mapped domain name to the new site
Step One – Setup A WordPress Multisite Network
All of the setup steps have been detailed by the guys and gals at WordPress. You should check out their documentation on it before proceeding. If you’ve already setup your network, continue on to Step 2.
Step Two – Install and Configure the WordPress MU Domain Mapping Plugin
This plugin is no run-of-the-mill WordPress plugin in the repo. It’s REQUIRED that you install this plugin MANUALLY. Here’s the deets:
- Download the WordPress MU Domain Mapping Plugin.
- Extract the zip archive to a location of your choosing. If you’re in need of a program to extract the archive, we recommend 7-Zip. We also recommend downloading it and other utilities from Ninite.
- Navigate to your “/wp-content/” directory on your WordPress site and create a folder called “mu-plugins”.
- Verify that you also have a folder titled “/blogs.dir/” within the “/wp-content/” folder as well.
- From the location where you extracted the plugin, we’re going to copy two files: “domain_mapping.php” and “sunrise.php” into the “/mu-plugins/” directory and “/wp-content/” directory, respectively. Please compare to the screenshot here to verify that you did this correctly.
- Navigate to the root of your WordPress install and open “wp-config.php”.
- Insert the following:
define( 'SUNRISE', 'on' );
and make sure it appears above the following line
/* That's all, stop editing! Happy blogging. */
- Upload your updated “wp-config.php” file to your web host.
- Log into your WordPress site and navigate to the “Network Admin” section.
- Click Settings > Domain Mapping. This is the interface for configuring your domain mapping across the entire network.
- Find the IP address of your web hosting server and enter that information into the Server IP Address field. You can also use a CNAME record instead if that’s your preference. You can find this information by pinging by your domain or within your web host’s admin panel (e.g. HostGator uses cPanel and your server’s IP address can be found in the sidebar to the left, all the way at the bottom of the screen under Account Information > IP Address).
- The Domain Options checkboxes below are important to decide how the mapping and subsequent redirection is handled. To explain what each of these options means:
- Remote Login – This forces all login attempts to be redirected to the main site’s URL. For instance, if we had this enabled, all of our network sites would be forced to redirect to http://fronterahouse.com/ to log in. We don’t want this, so it’s disabled.
- Permanent redirect (better for your blogger’s pagerank) – This enables the use of a 301 redirect instead of a 302. We recommend turning this setting on.
- User domain mapping page – Enables a site-specific domain mapping interface page located under Tools > Domain Mapping. We recommend this if you allow users to register their own site.
- Redirect administration pages to site’s original domain (remote login disabled if this redirect is disabled) – Much like Remote Login, this makes use of redirecting the user from their URL to your URL, but the big difference here is that this applies to ALL administration pages. This is up to you, but we leave ours turned off.
- Disable primary domain check. Sites will not redirect to one domain name. May cause duplicate content issues. – This is NOT recommended for proper SEO. Enabling this setting ignores redirections from non-WWW to WWW and vice versa. This can create major issues with duplicate content in search engines.
Step Three - Create An Additional Site Within Your Network
This step is very straightforward. Navigate to your Network Admin Dashboard and click Sites > Add New. Fill in the details as you see fit, click Add Site, and your new site has been created.
Step Four – Configure Settings With Your Registrar/Hosting Provider
At this point, we need to discuss a few things about domains, registrar’s, and hosting. When you purchase your domain name, you’ll use a domain registrar to do this. Typically domain registrars will also offer web hosting so that their customers can have an all-in-one place to manage everything from. GoDaddy or DreamHost are good examples of companies that provide both services in one place.
However, you can also choose to purchase your domain at one place and your web hosting elsewhere. For instance, you could have GoDaddy as your registrar, but you could use Bluehost for your hosting. Or you could have DreamHost as your registrar, but use HostGator as your hosting provider.
The reason I bring all of this up is that if you split your domain registration and your web hosting between companies, you’ll need a way to tell the registrar where your hosting is located. We do this with name servers.
The crucial point here is this: set your domain name servers to point to your hosting BEFORE you begin doing any domain mapping work with WordPress and let the information propagate.
Why is this so important? Without getting too complex, changes to name servers and DNS records can get pretty complicated due to “propagation” and TTL (time-to-live) values. It’s crucial to have these values set properly beforehand so that if you make a mistake with your WordPress multisite domain mapping, you can then eliminate DNS as a potential culprit when troubleshooting. For more information on DNS and propagation, DreamHost has a really good Wiki topic on it.
After changing your name server settings at your registrar, give the system time to update before proceeding to the next step of this guide. Usually, name server changes occur after about an hour, but sometimes these can take longer. DNS and name server changes can (but often don’t) take 24-48 hours to fully propagate around the internet.
As an additional tidbit of info, I’ve included links to some major hosting and domain registrar providers’ “how-to” sections for setting DNS and name server information:
Step Five - Assign A Mapped Domain Name to the New Site
Finally, we’re on to the good stuff!
Provided you changed the name servers in the previous step and let them propagate, all changes from this point on should be instantaneous.
We’ll now finalize the domain mapping settings for your new site and get this ball rolling:
- Log into your new site’s dashboard.
- Click on Tools > Domain Mapping.
- Under the Add new domain section, you should see a box preceded by “http://”. Type your domain name in this box (e.g. “www.mysite.com” or “mysite.com”), but DO NOT check the checkbox for Primary domain for this blog.
- Click the Add button to save your new domain name.
- You’ll now see two domain name options under the Active domains on this blog section with radio buttons next to them. The radio button should be in front of the current URL to access your site.
- You should now add another domain name that either includes the “www” in the URL or excludes “www” depending on how you entered it on Step 3 and add this exactly like you added the previous one. This is important for SEO purposes as Google can potentially see your site as two individual sites if not properly handled, which you definitely do NOT want. By adding both here, you can ensure that the “non-www” URL forwards to the “www” URL or vice versa.
- At this point, I highly recommend double- and even triple-checking your work up to this point to ensure that all of the steps have been completed properly. After completing the next step, you will be logged out of the dashboard and if you didn’t let your name servers propagate, you won’t be able to log back into your site dashboard until it finishes propagating.
- When you’ve reviewed that you completed all the steps properly and the name server records are properly updated, click the radio button next to the domain name that you wish to be primary for your site.
- Click the Set Primary Domain button.
- You’ll now be logged out of the site. If you look in your omnibox of your browser, you should notice that the URL has updated for your site. If you’re unable to log back into your site, don’t panic! You haven’t allowed for the propagation of the DNS servers to take into account your name server changes so you just need to be patient and give it more time. I’m an impatient guy myself, so I understand how difficult it can be to just sit and wait, but that’s what you’ll need to do.
Conclusion – WordPress Multisite Domain Mapping
At this point, you should be rock-n-rolling with your shiny new domain name pointed to your WordPress install! You should also have the “non-www” forwarding to the “www” or vice versa and everything should be dreamy, right? Well if it’s not for any reason, leave us a comment below or give us a shout on our contact form and let us know. We’re always willing to help out.