Multiple domains for multiple single installs

Serve both sites from the same installation.

In your wp-config.php include the settings depending on $_SERVER['HTTP_HOST'].

Example for a complete wp-config.php:

define( 'DB_HOST',     'localhost' );
define( 'DB_CHARSET',  'utf8' );
define( 'DB_COLLATE',  'utf8_general_ci' );

if ( 'example.net' === $_SERVER['HTTP_HOST'] ) // .net domain
    include 'example.net.config.php';
elseif ( 'example.com' === $_SERVER['HTTP_HOST'] ) // .com domain
    include 'example.com.config.php';
else
    die( 'something went wrong' ); // improve this error message

defined( 'ABSPATH' ) || define( 'ABSPATH', dirname( __FILE__ ) . "https://wordpress.stackexchange.com/" );

The .htaccess rewrite rules for single site installations are always the same, so don’t worry about conflicts.

If there are some identical settings in example.net.config.php and example.com.config.php you can move these to the main file, the authentication keys and salts for example or basic DB constants.

Leave a Comment