Mapping Multiple Domain Names - Two As Primary

Okay, I have a domain mapping questions that's making me run circles in my head. We have a WPMU network setup using subdomains. We use domain mapping plugin to map domain names to these sub domains.

We have one site in particular, where the client owns multiple domain names. So, we've entered all domain names into the domain mapping plugin page. So now we have say 4 domain names all mapping to one main domain name.

There is one domain name in particular that we what to make sure remains in tact in the address bar; without redirecting to the primary domain.

Ex. - set as primary domain name - redirects to - redirects to - remains in the address bar

*We don't want to disable primary domain check on our entire network. And we don't want to disable primary domain check for this one site. (screenshot attached)

We do want to make sure that one of the domain names being mapped does stay in tact in the address bar. Not sure if this can be done with a CNAME for this particular domain name, or if we can somehow accomplish this in the .htaccess file, or via functions.php theme file, etc......

Anyone have suggestions for how to accomplish this? Any help would be greatly appreciated!!!

  • Philip John


    Can I just clarify with you one thing - you said "we've entered all domain names into the domain mapping plugin page". Does this mean you've entered multiple domains into Tools > Domain Mapping for your clients site?

    Can you show me a screenshot of that page?

    You should only be able to map one domain to a sub-domain. If you want other domains to point to that site you will need to use redirecting services, typically provided by domain registrars.


  • borellidesigns

    Hi Phil!

    Attached is a screenshot.

    I'm thinking I can add a CNAME or something to the domain registrar. But I should still enter an IP address for the A records. With the A record pointing to the IP address, it would not resolve to the site, but rather the server's default web page.

    Adding the domain through domain mapping, plus an alias domain name through our server cPanel, then directs the domain name, pointed to our IP address, to the correct WPMU site.

  • Mason

    Hiya Gary,

    You're right our plugin does allow for that define. Good eye :slight_smile:

    As to the best way to go about this, I'd say a 301 redirect either at the domain registrar or through the htaccess file would be the best route. Using a CNAME would be the solution if wanted the URL to remain consistent with whatever the user originally types in/looks at.

    My personal recommendation would be to do it through the domain registrar (no chance of anything ever messing this up - and the least configuration necessary).

    Hope that helps!

  • Sean Grant

    Add //define('DOMAINMAPPING_ALLOWMULTI', 'yes'); to wp-config.php to enable mapping of two or more domains to one multi-site website.

    Use CNames to point the domains to the wp network site

    eg: CNAME 14400 CNAME 14400

    This way calls for and will both be redirected to the same website, while retaining their respective URL's

    eg: or

    NB: This solution requires a DEDICATED IP address assigned to your primary WP Network domain.

    A neat and simple solution....

  • James Ong

    Hi, how are you?

    Although this thread is four years old and the last reply was in 2014, it looks like this is not completely solved yet? I have a similar issue so I am not creating a new thread.

    I am using the multi-domain and domain mapping plugins, both from WPMUDEV, and besides other functions, I want to map another domain to the primary domain, that is having two as primary domains, one in the root and the other being mapped and acting as a primary domain too.

    That is, as in the original posting by borellidesigns:-

    We do want to make sure that one of the domain names being mapped does stay in tact in the address bar.

    I used the CName (together with the two plugins: domain mapping and multi-domain on) as also suggested by Sean Grant in the last post but it still did not work. In this case, the additional domain can be redirected but does not retain its URL in the Web browser address bar.

    As I could not find any solution here, I had also submitted a ticket to WPMUDEV but no solution at all as it seems to rely more on this forum than on their own support. We probably have to add something to .htaccess? Is there any solution towards this issue?

    I would greatly appreciate to have a solution given that this thread is already four years old. :slight_smile: Thanks a lot in advance...

    Best Regards,

  • Daniel H.

    In my opinion, ignoring the "Front end redirect should be" == "Disabled and entered domain should be used" dropdown setting is a BUG.

    Anyway, in case someone finds this useful in their searches, this worked for my setup (YMMV; Ubuntu 16.04 LTS, PHP 7.0, ServerPilot, Nginx+Apache, latest WP [4.7.4] and plugin [] at the time of this post). This is not an ideal solution at all because it is going to require me to re-add the changes whenever the plugin is updated. Hopefully, WPMU DEV can provide a supported solution, but the OP was posted in 2011. :disappointed:

    I added the following to the bottom of this file:

    // Hack by Daniel
    if ( is_multisite() && !defined('WPMU_DM_SITE_ID')) define('WPMU_DM_SITE_ID', get_current_blog_id());
    // End Hack

    (I added the opening/closing comments to make it easier to grep for when I inevitably have to add it to an updated version and forget which files I changed.)

    Changed classes/Domainmap/Utils.php, function _set_mapped_domains() -


    private function _set_mapped_domains(){
            $results = $this->_wpdb->get_results( "SELECT blog_id, domain, is_primary  FROM " . DOMAINMAP_TABLE_MAP );
            foreach( $results as $result ){
                self::$_mapped_domains[ $result->blog_id ] = $result->domain;
                if( $result->is_primary  )
                    self::$_mapped_primary_domains[ $result->blog_id ] = $result->domain;


    private function _set_mapped_domains(){
            $results = $this->_wpdb->get_results( "SELECT blog_id, domain, is_primary  FROM " . DOMAINMAP_TABLE_MAP );
            foreach( $results as $result ){
                //self::$_mapped_domains[ $result->blog_id ] = $result->domain;
                // Hack by Daniel
                $wpmu_dm_requested_domain = preg_replace('#^www\.(.+\.)#i', '$1', $_SERVER['HTTP_HOST']);
                self::$_mapped_domains[ $result->blog_id ] = $wpmu_dm_requested_domain;
                if(defined('WPMU_DM_SITE_ID') && is_int(WPMU_DM_SITE_ID)) {
                    global $wpdb;
                    self::$_mapped_domains[ $result->blog_id ] = $wpdb->get_var( $wpdb->prepare( "SELECT domain FROM $wpdb->domain_mapping WHERE blog_id = %s AND domain = '%s'", WPMU_DM_SITE_ID, $wpmu_dm_requested_domain ) );
                // End Hack
                if( $result->is_primary  )
                    self::$_mapped_primary_domains[ $result->blog_id ] = $result->domain;

    (NB: I had to make some small changes to this code that as posted because it had some special references that were specific to my install. There may be a typo, but hopefully you get the idea.)

    EDIT: You can't set any of your domains as primary else it will redirect to the primary and ignore my code. I could fix that, too, but I do not need it for my purposes, so game on!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.