WordPress – several domains for the site

WordPress – several domains for the site

In order to make a site on WordPress pratsyuvav on a number of domains. write in wp-config next code:

$array[0] = array(
    'domain1.com', 
    'domain2.com',
    'domain3.com',
    'domain4.com',
);

if (array_intersect(explode(' ', $_SERVER['HTTP_HOST']), $array[0])) {
    $glob_host = $_SERVER['HTTP_HOST'];
}
else {
    $glob_host = 'domain1.com';
}
define( 'WP_HOME', 'http://' . $glob_host . '' );
define( 'WP_SITEURL', 'http://' . $glob_host . '' );

Now the site will work on the domain1.com-domain4.com domains.