Mulitdomain multisite WP3 Installation

Welcome! This post describes how to enable wordpress 3.x for multiple domains and allow each site to enable subdirecroty blogs using the network multisite option.

Each domain will use a different table_prefix as described by Richard. But using a diffent approach to dynamically select table_prefix. You must be able to point your domain or subdomain to your wordpress installation directory.

      1. Install WordPress
      2. Enable multisite option in wp-config.php
      3. Before setting up your first site, ad following lines in wp-config.php to ensure each domain uses a different table prefix.
        In wp_config.php look for

        $table_prefix = ‘wp_’;

        and add follwoing lines after $table_prefix = ‘wp_’;

        $table_prefix  = ‘wp_’;
        if ($_SERVER[‘HTTP_HOST’]) {
        $http_hs=explode(“.”,strtolower($_SERVER[‘HTTP_HOST’]));
        $table_prefix = $http_hs[count($http_hs) – 2].’_’;
        $table_prefix = str_replace(“-”, “_”,$table_prefix);
        }

      4. Now, create your first blog in the first domain you want to use.
      5. Next, enable the WP3 Network for subdirectories. This allows WP3 to split the content. Follow the instructions given for .htaccess and wp-config.php.
      6. Before log in next time to your first domain blog, change wp-config.php, Replace

        define( ‘MULTISITE’, true );
        define( ‘SUBDOMAIN_INSTALL’, false );
        $base = ‘/’;
        define( ‘DOMAIN_CURRENT_SITE’, ‘<domain>’ );
        define( ‘PATH_CURRENT_SITE’, ‘/’ );
        define( ‘SITE_ID_CURRENT_SITE’, 1 );
        define( ‘BLOG_ID_CURRENT_SITE’, 1 );

        with

        switch ($_SERVER[‘HTTP_HOST’]) {
        case “<domain>”:
        define( ‘MULTISITE’, true );
        define( ‘SUBDOMAIN_INSTALL’, false );
        $base = ‘/’;
        define( ‘DOMAIN_CURRENT_SITE’, $_SERVER[‘HTTP_HOST’] );
        define( ‘PATH_CURRENT_SITE’, ‘/’ );
        define( ‘SITE_ID_CURRENT_SITE’, 1 );
        define( ‘BLOG_ID_CURRENT_SITE’, 1 );
        break;
        default:
        ;
        break;
        }

        This allows to control which domain should use the network configuration of wordpress

      7. Next, you must ensure that all domains use different upload directory paths. WordPress ensures this for all subdirectory blogs except the first blog you created. Login in to your domain blog, in SuperAdmin select your first blog and edit your configuration. For the blog with ID 1 change the upload path from

        Upload Path: wp-content/files

        to

        Upload Path: wp-content/blogs.dir/1/files

      8. That’s it, your are fine for your first domain!
      9. Now, create the blog for your next domain and again enable Network for Subdirectories.
      10. Logout from your <domain2> and modify your wp-config.php. Change

        switch ($_SERVER[‘HTTP_HOST’]) {
        case “<domain>”:

        to

        switch ($_SERVER[‘HTTP_HOST’]) {
        case “<domain>”:
        case “<domain2>”:

        This allows your domain to use subdirectories and automatically split the content of the blogs also for this subdomain.

      11. Login to your <domain2> blog and modify again the upload path option for the first blog (blogid 1):

        Upload Path: wp-content/blogs.dir/101/files

        Choose for the subdirectory a number as high as you expect never to reach for subdirectory blogs in your first domain!

      12. Next, you need to ensure that blogs created in your new domain use automatically a directory path which is different from the previos domain path directorys. To ensure that, login to your mysql database and insert a row in the table <domain_prefix>_blogs where blog-id is, in this case, 101. Remove the row again. Next entry to the row will have the id 102, files will be placed in a separate directory by default for the next blog you create.
      13. Now create your first site in your domain, which will automatically have id=102.
      14. Repeat steps 9-13 for all domains you will use.