{"id":815,"date":"2024-02-21T23:26:34","date_gmt":"2024-02-21T23:26:34","guid":{"rendered":"https:\/\/lynton.dev\/?p=815"},"modified":"2024-03-05T00:47:39","modified_gmt":"2024-03-05T00:47:39","slug":"multiple-domains-loading-the-same-wordpress-website","status":"publish","type":"post","link":"https:\/\/lynton.dev\/multiple-domains-loading-the-same-wordpress-website\/","title":{"rendered":"Multiple Domains Loading the Same WordPress Website"},"content":{"rendered":"\n

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<\/strong> and .com<\/strong> domains have been registered. When navigating to the .com<\/strong> and .ca<\/strong> domains, each respective URL will be shown in the address bar with the exact same website being loaded.<\/p>\n\n\n\n

\n

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.<\/p>\n<\/blockquote>\n\n\n\n

Modifying wp-config.php<\/h4>\n\n\n\n

By modifying the wp-config.php<\/strong> file, multiple domain urls can be configured to load the same WordPress website.<\/p>\n\n\n\n

Add the following lines to\u00a0wp-config.php<\/strong>\u00a0in the website application root folder:<\/p>\n\n\n\n

define('WP_SITEURL', 'http:\/\/' . $_SERVER['HTTP_HOST']);\ndefine('WP_HOME', 'http:\/\/' . $_SERVER['HTTP_HOST']);<\/code><\/pre>\n\n\n\n

Before the line:<\/p>\n\n\n\n

\/* That's all, stop editing! Happy blogging. *\/<\/code><\/code><\/pre>\n\n\n\n

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

Domain DNS<\/h4>\n\n\n\n

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:<\/p>\n\n\n\n