How to Use Domain Mapping When You’re Not Running Multisite

How to Use Domain Mapping When You’re Not Running Multisite

Mapping domains is super easy in Multisite. It lets you create as many sites as you want in one WordPress installation and then makes them all behave as if they’re separate sites on their own domain.

But sometimes you want to map a domain when you’re not running Multisite. Say you’ve created a site in its own WordPress installation somewhere on your server, maybe in a subdirectory, but you want to direct it to an external domain name. You want the custom domain name to show up in the browser, instead of the primary domain with the subdirectory or subdomain showing up.

By default, WordPress domain mapping functionality only works with Multisite setups, so you can’t use that to map domains within a single WordPress installation. And if you’re on hosting accounts that allow only one domain, you can still bypass that restriction with this method.

The good news is that you can map a domain to a subdirectory on another domain, so it works in just the same way. We’ll be doing this by using cPanel and changing some WordPress settings.

How to map domains in four steps:

  1. Register the domain and configure it to point to your server if it isn’t already.
  2. Add the domain to your hosting account, using cPanel.
  3. Wait for your DNS changes to take effect.
  4. Update the Subsite addresses (URLs).

So let’s go through the process step-by-step.

1. Register The Domain And Point It To Your Server

You can’t do any of this without a domain registered. So begin by registering a domain with the registrar of your choice.

If you register your domain with your hosting provider, it will automatically direct to their nameservers, so you won’t then have to configure it to point to your server. You can go straight to Step 2.

But if you use different providers for hosting and domains (which is highly recommended), or if your client has registered the domain and you’ve created a site for them, you must configure the DNS settings for the domain.

Go to your domain registrar’s admin screen and edit one of the following options:

Nameservers

If you want all the DNS records of the domain to point to your hosting server (which for most of us means the domain itself and any email addresses associated with it), then change its nameservers (NS records).

I use Big Wet Fish for my domains. Here’s their admin screen for changing nameservers:

Big Wet Fish nameserver editing
The admin screen for changing nameservers on my domain.

The screen for your domain registrar will look different but will be essentially similar. You get the nameservers from your hosting provider – they’ll send these when you sign up and you can find them in their admin screens or on cPanel. I use SiteGround for my hosting, and they display their nameservers in cPanel:

nameservers displayed in cPanel

That gives me the values I need to add to my registrar’s nameservers admin screen.

Note: If you want to direct a domain to your nameservers but have your email hosted elsewhere, and you’ve directed the domain to your hosting provider’s nameservers, then you need to edit the DNS for email (or the MX records) in your hosting provider’s admin screens.

CNAME

I’ve mentioned above that if you don’t want your domain’s email address hosted with your hosting provider, you can edit this on your hosting account. This means that your DNS for email will redirect twice. If you want to avoid this and either keep email with the domain registrar or direct it somewhere else (such as Gmail) from your registrar’s admin screens, you can do this by editing the CNAME value for your domain instead.

The CNAME points to the domain you want the original domain to redirect to. So if you want mydomain.com to point to myhosting.com/mydomain, you’d add myhosting.com/mydomain in your domain registrar’s admin screens.

Here’s my registrar’s DNS admin screen, showing the options you have:

DNS editing showing options for DNS management

If you use the CNAME, select CNAME (Alias) and type the address for the new site on your hosting (i.e. myhosting.com/mydomain) in the Address field. The domain will automatically point to the right place and you can skip the next step which is creating the add-on domain.

A Record

Another option is to configure the A record for your domain to point to the IP address where your hosting is.

Like the CNAME record, this only affects the website, not email. Use the same DNS screen as you would for the CNAME, select A and type in the IP address. Your hosting provider will give you this or you’ll be able to find it in cPanel or your hosting admin screens.

Note: If you do this, you must still set up the add-on domain.

2. Create An Add-On Domain

You can skip this step if you used the CNAME option above.

In cPanel, which your hosting provider will give you access to, go to the Domains section:

domains section of cPanel

Select Add-on Domains. This will take you to a screen where you need to enter the domain name that you’ve directed to your server:

configuring an addon domain

Type the URL of the domain (without http or www) in the New Domain Name field, and enter the subdirectory which stores your site in the Document Root field. Using the example above, I’d type mydomain.com and mydomain, respectively.

If you want to create a FTP account for this site, then add the details in the FTP Username field. Create a password for your new domain and click on Add Domain.

3. Wait For DNS To Take Effect

This can take anything from a few minutes to even 48 hours. And you have no control over it. You simply have to wait, as it takes some time for your domain’s updated DNS records to propagate.

If you want to monitor its progress, check out the whatsmydns site to see where in the world your DNS is resolving correctly. Here’s my site’s DNS:

 

Whatsmydns.net shows my site's name servers
My site’s DNS.

 

Note: My DNS points to CloudFlare because I’m using that with our Hummingbird plugin for performance.

If there are any problems, this is a useful tool to track them.

4. Update the Site Addresses (URLs)

Once you’ve redirected your domain, created an add-on domain and the DNS changes have taken effect, the redirect will work. When you type mydomain.com into a browser, it’ll direct you to myhosting.com/mydomain.

But the URL in the browser will still show up as myhosting.com/mydomain. You want it to show up as mydomain.com.

To change this go to Settings > General in your WordPress admin screens. The two fields you need to edit are WordPress Address (URL) and Site Address(URL):

editing site url and WordPress url in settings

Both these read myhosting.com/mydomain now. Edit them, so they read mydomain.com. And then click Save Changes.

Because you’ve changed your site’s domain, you need to log in again. If you find your site doesn’t work properly, then clear your browser cache and flush your DNS cache. Once you’ve done that, you’ll find that your site’s domain mapping is the same as it is with WordPress Multisite domain mapping.

Mapping Domains Is Easier Than You Think

By following these four steps, you can map a domain you’ve registered to a subdirectory of your hosting account. It’ll behave as if it’s hosted along with the domain. This can be useful if you need to direct a second or alternative domain to your site. You can safely create multiple instances of WordPress on your hosting account without having to set up multiple hosting accounts, each with their own domain. This will save you money while getting the same results.

Get mapping!

Tags:
Rachel McCollin
Rachel McCollin Rachel is a freelance web designer and writer specializing in mobile and responsive WordPress development. She's the author of four WordPress books including WordPress Pushing the Limits, published by Wiley.
Salman Ravoof
Salman Ravoof A self-taught web developer, writer, and creator. He finds science, philosophy, technology, and food exciting. When he's not busy exploring the dankest memes on the web, he can be found petting cats and cooking delicious meals. And sleep, lots of it!
Have you tried domain mapping a WordPress site? How did it go? If you need help, don't hesitate to ask in the comments below.