admin管理员组

文章数量:1022834

I need to have two domains show the same WordPress blog along with the same content on my multisite install.

The main blog's domain is example/blog, and I need to have example.ca/blog showing all the content that appears on example/blog.

I've added an A record in my cloudflare on the example.ca domain pointing to the ip of the example/blog, along with the code below to my wp-config.php, but it's not working.

$hostname = $_SERVER['HTTP_HOST'];
if(!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
    $hostname = $_SERVER['HTTP_X_FORWARDED_HOST'];
}

$hostname = rtrim($hostname, '/');

$allowed = ['example', 'example.ca'];

if (!in_array($hostname, $allowed)) {
    $hostname = 'wpengine';
}

$protocol = (!empty($_SERVER['HTTPS']) || !empty($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'))
            ? 'https://'
            : 'http://';

$siteUrl = $protocol . $hostname;

define('WP_HOME', $siteUrl);
define('WP_SITEURL', $siteUrl);

I need to have two domains show the same WordPress blog along with the same content on my multisite install.

The main blog's domain is example/blog, and I need to have example.ca/blog showing all the content that appears on example/blog.

I've added an A record in my cloudflare on the example.ca domain pointing to the ip of the example/blog, along with the code below to my wp-config.php, but it's not working.

$hostname = $_SERVER['HTTP_HOST'];
if(!empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
    $hostname = $_SERVER['HTTP_X_FORWARDED_HOST'];
}

$hostname = rtrim($hostname, '/');

$allowed = ['example', 'example.ca'];

if (!in_array($hostname, $allowed)) {
    $hostname = 'wpengine';
}

$protocol = (!empty($_SERVER['HTTPS']) || !empty($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'))
            ? 'https://'
            : 'http://';

$siteUrl = $protocol . $hostname;

define('WP_HOME', $siteUrl);
define('WP_SITEURL', $siteUrl);

本文标签: Display same site from two domains on a multisite install