Setting up WordPress MultiSite

Being able to run multiple WordPress sites from a single install of WordPress is a nice concept and one that actually works. The biggest issue with it is that all of the instructions I have seen on how to set it up appear to be incomplete. In particular I found the instructions for allowing multiple domains to be completely misleading. The problem is that the instructions on some parts of the setup deal with how to set it up to work the way the author has their server configured without their mentioning what that configuration is and their not covering that it is possible to set it up completely differently when the configuration is different.

I am not going to pretend that these instructions cover all situations, instead I will start out by specifying the particular server configuration for which the following instructions will work. The following instructions assume that you will pre-define all of the domains and sub-domains that you want to use with multisite configures to point to the directory on the server where you have WordPress installed. This directory need not be the root directory of your hosting account. How you get the domains and sub-domains pointing there will depend on what control panel you are running or on being able to directly update the appropriate Apache configuration files. The following instructions do not allow for you to have domains added via WordPress, they must all exist before you can add them to your multisite. Note that most of this matches what you will read elsewhere about the basic setup but there are a couple of minor differences.

The first thing to do is to edit the wp-config.php file to add the following entry:

define( 'WP_ALLOW_MULTISITE', true );

You can now access the Network Setup option within your WordPress install by going to example.com/wp-admin/network.php (where example.com is the main site you initially used to install this copy of WordPress. This will allow you to specify a network title and email address. WordPress will now add the extra tables into the database that are required to use MultiSite. You will then be provided with some code to add to your .htaccess file and extra code to add to your wp-config.php file.

The code provided to add to your .htaccess file should look something like this:

RewriteEngine OnMbr/>RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
 
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
 
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

The code to add to the wp-config.php should look something like this (with your domain name substituted for example.com):

define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

Note that the above configures the multisite to work with sub-domains and domains. If you are planning on using sub-directories instead then you are reading the wrong instructions.

While you are adding code to wp-config.php you should also add the following line (which is required to allow back end access to any other domains you point to this install):

define('COOKIE_DOMAIN', false);

Your install is now basically complete except for adding the extra domains and sub-domains that you want to share this copy of WordPress. To set them up first point the domain or sub-domain to the directory containing this WordPress install and wait a few minutes for the domain to point to the correct place. You can then go into the Network Admin 'Create a New Site' option to add these domains/sub-domains. This will create the extra tables in the database for the individual blogs as well as sub-directories to hold the files for the specific site. You can also choose which theme the site is to use from those installed and also choose whether to activate individual plugins that have been installed but not activated for the entire network.

Note that the extra line added to the wp_config.php file prevents the different domains from trying to share cookies (which they can't do anyway) and so instead of getting a cookies not supported error when you try to access an admin panel for a different domain you will instead simply be asked to login again.

Note that these instructions do not go into any details on actually creating and configuring the individual sites as there are plenty of other guides around that cover these aspects of setting up multisite. This guide is intended for those who want to be able to set up specific domains and sub-domains on multisite without allowing people to create their own and without having to install multisite in the root directory in order to be able to use the domain mapping plugin.

go to top

FaceBook Follow
Twitter Follow
Donate