I have an two wordpress sites that I would like to host on the same domain. One is already up and running, the other is sitting in waiting.
Can I get the second as a subdomain, or simple within a folder, to run on the same domain (different DB) without converting to multisite?
2 Answers
Point the subdomain to the same directory as the main site, and define different settings in your wp-config.php per $_SERVER['HTTP_HOST']
:
Example from my local setup:
switch ( $_SERVER['HTTP_HOST'] )
{
case 'zzl.dev':
$table_prefix = 'zzl_';
$table_name="zzl";
break;
case 'wpbuch.dev':
$table_prefix = 'wpbuch_';
$table_name="wpbuch";
break;
default:
$table_prefix = 'wp_';
$table_name="wpdev";
break;
}
$sub = '/wp-content/' . $_SERVER['HTTP_HOST'];
const WP_CONTENT_DIR = __DIR__ . $sub;
const WP_CONTENT_URL = 'http://' . $_SERVER['HTTP_HOST'] . $sub;
const DB_NAME = $table_name;
You can change much more variables in the switch: all DB_*
definitions, WP_PLUGIN_DIR
and WP_PLUGIN_URL
(to share the plugin list between different sites), WPLANG
and so on.