Domain not redirected correctly with Wordpress Multisite

My Wordpress multisite installation uses two sites:

Site 1: www.myexample.com
Site 2: blog.myexample.com

In addition, I own a second domain myexample2.com, which I would like to redirect to the subdomains of the original domain.

Here are its CNAME records in DNS settings:

; A Records
@   600  IN     A   xxx.xxx.xxx.xxx

; CNAME Records
blog    600  IN     CNAME   blog.myexample.com
www 600  IN     CNAME   www.myexample.com

The problem is that when calling blog.myexample2.com the home page www.myexample.com gets loaded instead of blog.myexample.com.

The problem seems to be in some Wordpress setting, wp-config.php may be causing this.

Part of wp-config.php related to Multisite:

/* Multisite */
define( 'WP_HOME', 'https://www.myexample.com' );
define( 'WP_SITEURL', 'https://www.myexample.com' );
define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'www.myexample.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 2);

define( 'NOBLOGREDIRECT', 'https://www.myexample.com' );

Topic site-url dns domain-mapping wp-config multisite Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.