WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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';

    case 'wpbuch.dev':
        $table_prefix = 'wpbuch_';
        $table_name   = 'wpbuch';

        $table_prefix  = 'wp_';
        $table_name   = 'wpdev';

define( '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.

share|improve this answer
Is this all I have to do to add a subdomain? – Mild Fuzz May 11 '11 at 10:27
@Mild Fuzz: Yes, I’m running several live sites with this setting, even some multisites. – toscho May 11 '11 at 10:33
so this is just a case of having all themes and plugins in the same install, and just calling the different databases? Ultimately it is one install? – Mild Fuzz May 11 '11 at 10:35
@Mild Fuzz Yes, it is. If you update one site, the other sites are up to date too. Try it in your local setup, it’s a matter of minutes. – toscho May 11 '11 at 10:50
@toscho How does this work out when you come to upgrade plugins and wordpress? Does it play nice? – Brady May 11 '11 at 12:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.