Multiple Domains Loading the Same WordPress Website

Given multiple domains, the goal is to load the same website regardless of which is entered in the address bar. For example, say the .ca and .com domains have been registered. When navigating to the .com and .ca domains, each respective URL will be shown in the address bar with the exact same website being loaded.

Note: this endeavor shouldn’t be confused with a WordPress Multisite. A multisite allows the management of different websites from the same single WordPress dashboard.

Modifying wp-config.php

By modifying the wp-config.php file, multiple domain urls can be configured to load the same WordPress website.

Add the following lines to wp-config.php in the website application root folder:

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);

Before the line:

/* That's all, stop editing! Happy blogging. */

These two added lines set the WordPress Site URL and Home URL based on the domain being passed to the site. Note, after setting these URL’s in wp-config.php , they can’t be configured from the WordPress admin panel (Settings page).

Domain DNS

After the primary domain DNS is configured, set up the subsequent domain(s) DNS using the records from the primary domain as a reference. For the subsequent domains:

  • an A record is needed to point to the web server
  • CNAME record to allow www
  • and another CNAME record that contains the WordPress application url