If you are reading this article you probably already know this, but WordPress Multisite Domain Mapping allows your_subsite.your_mainsite.com to be mapped to show as anydomain.com. This means that you can have multiple domains pointing to the same WordPress Multisite install. How cool is that? The main advantage in my opinion is updating WordPress and plugins takes an immediate effect on all websites.
While working on my new SaaS project spotsy.me I found some outdated documentation and tutorials about this process. It is outdated mostly because before WP 4.5 the process was harder and required plugins or a script called sunrise.php
This scenario was the kick-off for writing this article.
Requirements
Before you start make sure that you follow these requirements:
- WordPress 4.5 or higher
- A fully functional WordPress Multisite based on sub-domains. Probably it can be based on directories too, but I haven’t tested yet. If you need help with this step please head to https://codex.wordpress.org/Create_A_Network
- FTP access to the file system, because you’ll need to edit the wp-config.php
- This isn’t really a requirement, but make sure that you backup your database in case you need to revert the process for any reason
5 easy steps for Multisite Domain Mapping
In this quick example we’ll be using the following domain names:
your_mainsite.com – the main website of our Multisite install
your_subsite.your_mainsite.com – the sub-site that we want to map as another domain
anydomain.com – the domain that we want to point to our sub-site
Step 1: Add your domain as an Addon Domain on your hosting control panel
When doing this please make sure that the Document Root is the same as your main website (Ex: “public_html”)
Step 2: Install SSL certificate
If you aren’t still using SSL, you should. So, after configuring your new Addon Domain, make sure that you generate a new SSL certificate. If you are using cPanel look for “Let’s Encrypt”
Step 3: Adjust the sub-site URL
From your WordPress Dashboard click on My Sites>Sites and Edit your_subsite.your_mainsite.com. You’ll need to edit the Site Address (URL) option – set it to anydomain.com
Step 4: Change the domain DNS
Our Multisite install is now ready to receive the mapped domain, but we haven’t “told” our domain that it should point to this Multisite yet. To achieve this head to your anydomain.com registrar and set the A or DNS record accordingly. If you are not sure about this step please ask your hosting company about the A or DNS record that should be entered on the domain registrar
Step 5: Edit the wp-config.php
After mapping the domain you’ll most likely get an error about cookies being blocked. To fix that simply add the line of code below right after the Network Setup on the wp-config.php file:
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);
As always, if you have any feedback on this tutorial or got stuck somewhere, please send me a message using the contact form below. I would love to hear from you.
Wow I’ve really wanted to do this in the longest time and your article really simplified it for me. Thank you so much!
Hi Mutaki,
I’m happy to hear that. Good to know that I was able to help.
Cheers!