1

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.com/blog, and I need to have example.ca/blog showing all the content that appears on example.com/blog.

I've added an A record in my cloudflare on the example.ca domain pointing to the ip of the example.com/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.com', 'example.ca'];

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

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

$siteUrl = $protocol . $hostname;

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.