WordPress Domain Mapping explained
October 26. 2020
While most websites use one domain, it is not uncommon for web developers to get multiple. This is usually done for larger websites with a far-reaching audience, where using a single domain is simply not enough. In such cases, web developers need to connect multiple domains to a single hosting service. And here is when domain mapping becomes important. With it, you can orient your domain so that they navigate your online traffic to the desired host, which makes dealing with website migration a whole lot easier. But, doing so is easier said than done. This is why we will not only cover what WordPress domain mapping is but when and how to use it.
What is WP domain mapping?
By default, WordPress will allow you to create additional network sites. These can either be subdomains or even subfolders, depending on what you use out of them will be. In certain cases, this is more than enough. But, if you would rather use WP multisite to manage distinct websites, you should make a unique domain name for them. Well, WP multisite domain mapping lets you do precisely that. While it is a bit more complicated to implement, it gives you all the benefits of setting up regular sites, with some extra benefits on handling different domains.
When to use WordPress domain mapping?
In practice, there are several situations where you might need to use WP domain mapping. The most common ones are:
- You are using multiple domains and you want them all to lead back to a single server.
- You own a single domain name, but the hosting provider is different from the one for your website server.
- Switching to a new CMS (Content Management System) while trying to maintain links on your current website.
All in all, if for some reason you plan on using a domain name that is not directly connected to your server host, you will have to use WP domain mapping. Only by doing so will you be able to redirect users to the current host while using the desired website address.
How to get started
The easiest way to handle WP domain mapping is through WordPress multisite. As of WordPress 4.5, you don’t have to use exterior plugins in order to handle domain mapping. While this makes doing so a bit more simple, we still advise you to fully familiarize yourself with the whole process before going at it. Also, remember to make a backup of your website before making any major changes. That way, you will be able to revert to the previous state without too much trouble.
Setting up WP multisite
The first thing to do is to set up the WP multisite network. To do so you need to install the standard WordPress software. Then you need to head on to the wp-config.php file and add the necessary code snippet. Doing so will enable your WordPress multisite. After that, you simply need to follow the interface instructions in order to set up the network. Once you do that, you will get two code snippets. One is for your .htaccess file, and the other is for the wp-config.php file. Once you are done setting up WP multisite, opt for subdomains. We recommend doing so simply because it makes handling domain mapping easier.
Adding a new site with Network Admin
With your WP multisite functioning, it’s time to add a new site to your network. To do so, simply go to the Network Admin interface and use the Sites -> Add New option. After adding the site, feel free to chose any subdomain or subfolder as you see fit, as we will change it soon. After you click on Add Site, head on to the Sites and click on the Edit button for the site in question. Here you can ether the external domain that you are going to map. By clicking on Save Changes, your website will now assume that the network site is located in the external domain.
Using the external domain as an alias for the host
Now you need to open the DNS records of your network site and add the external domain to it. There are multiple ways in which you can do this, which is why we will focus on the one that we deem easiest, which is through cPanel. Once you install cPanel, you need to find the Parked Domain or Aliases option (depending on the version on cPanel that you are using). Once you find it, enter the external domain and click Add Domain. In the Redirects To bracket choose the Manage Redirection option. Here you need to opt for Disable Redirection.
Orienting nameservers to your host
The final thing to do is to orient your nameservers to your host. More precisely, you want your external domain to point to the same nameserver as your WP multisite (this is usually where your WordPress is installed). This process is mostly dependant on where and how you’ve registered your external domain. Again, for simplicity, we are going to assume that you used GoDaddy, as it is the most common option. To change nameservers here you’ll need to:
- Sign in to your GoDaddy account.
- Head on to the Domain Settings page and select your domain.
- Choose the Manage DNS under Additional Settings.
- Choose Change in Nameservers settings.
- Pick the “Connect my domain to the website I’ve built” option, as it is the most straightforward one.
- If this doesn’t work, use the “Enter my own nameservers option”. It is a bit more complicated, but it gives you more control.
- Select either Connect or Save.
- Agree to “Yes, I consent to update Nameservers for the selected domain(s)”.
For all of this to take effect, you need to wait 48 hours. Expect that your website may malfunction or completely shut down during this time, as it is a relatively large task. If you think that there are performance issues after 48 hours, perform a security audit to ensure that there were no unauthorized changes to your website.