In the previous episode, I simply presented (at least I hope so) how to set up a multisite with WordPress. We saw that we could create as many sites as we wanted on the basis of a single WordPress installation.
The created sites had then 2 possible syntaxes :
- in subdomain ex : site1.example.com
- in sub-folder ex : example.com/site1
Admit that it’s a good start but if we could also have a personalized URL… then it would be perfect !
When I say personalized URL, I mean a site address like thivinfo.com for the first site and tartempion.com for the second.
This is precisely where domain mapping comes in.
Setting up the registrar side
Yes, you will have to set up the domain names you want to map at your registrar. I can’t detail the way to do it because it is specific to each host depending on the administration panel used.
Please note that if your domain name is managed by your host, you must point this domain to the root of the folder containing your WordPress installation.
Setting up the WordPress side
Once your domains are pointing to the right folder, you have to tell WordPress that it will have to manage one or more other domains.
Concretely, let’s imagine that I have a network of WordPress sites on the tuto-multisite.local domain and that on this network of sites I have a site https ://tartempion.tuto-multisite.local. https ://tartempion.tuto-multisite.local is a fully accessible URL (locally but the principle is the same on a public URL) and I could stay like that. Except that to communicate it would be easier to give as URL tartempion.com.
The goal is to make all the requests point to tartempion.tuto-multisite.local and send them to tartempion.com.
Installation of the extension
For this, we will use an extension available for free on the WordPress repository : https ://wordpress.org/plugins/wordpress-mu-domain-mapping/
We are in Multisite WordPress, so the installation of the extensions is done at the network administration level.

Then, as on a classic WordPress site, you look for the WordPress MU Domain Mapping extension, install it and activate it on the network.
Go to the network admin level in the “Domain Mapping” menu. And there : It does not work and you have a line saying :
“Please copy sunrise.php to /path/to/wp-content/sunrise.php and ensure the SUNRISE definition is in/path/to/wp-config.php”
Which can be translated as :
“Please copy sunrise.php into path/to/wp-content/sunrise.php and ensure you have defined SUNRISE in your wp-config.php file”.

Attention, here is THE complicated part of this tutorial dedicated to domain mapping !
In the extension directory under wp-content/plugins/wordpress-mu-domain-mapping you will find the file sunrise.php

Take this file and drag it under wp-content/

We just have to define a PHP constant to allow domain mapping in the wp-config.php
to the part where you have declared the multisite, add
define('SUNRISE', true);
to get something like :
define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'tuto-multisite.local');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('SUNRISE', true);
If you go back to the domain mapping settings you will see this new settings menu :

Save your settings and… your WordPress multi-site multi-domain is ready ! o/
Map your 1st WordPress domain
So we’ll map tartempion.com to tartempion.tuto-multisite.local.
Being local and not really owning the tartempion.com domain, I will modify the hosts file of my machine to simulate this domain.
I go to the administration of my site to be mapped https ://tartempion.tuto-multisite.local/wp-admin/ then in the menu “Tools/Domain Mapping”.
You will find this page :

Fill in your domain to map (donations my case tartempion.com without http or https). If the domain will be the main domain then check “Primary domain for this blog”. This way you will be able to have as many domains mapped for a site (the www.tartempion.com for example) but only one will be served.
Congratulations ! You have mapped your first domain !
Thanks to Bruno Tritsch for making the following video tutorial illustrating perfectly my tutorial.
