Quick Guide to Activating WordPress Multisite

I’ve come across seasoned WordPress developers who are still daunted by the prospect of setting up WordPress Multisite. It needn’t be this way – installing Multisite involves following just a few simple steps which I’ll show you in this quick guide.

Note: If you want more in depth content about Multisite, you can read my posts on other sites, which I’ve listed here.

I’ll run through:

  • Choosing between a subdirectory and subdomain installation
  • Editing wp-config.php to allow a network
  • Viewing your Network Settings in the dashboard
  • Editing .htaccess and wp-config.php (again) to complete the process

So, let’s get started!

Choosing Between Subdomains and Subdirectories

Before you start, you need to decide which type of installation you want: subdomain or subdirectory. What each of these means is as follows:

  • Subdomain installations give a subdomain to each new site created on your network. So if your network is at my http://network.com and you create a site called site1, its url would be http://site1.mynetwork.com.
  • Subdirectory installations use urls with subdirectories of the main url. So the site1 example above would have the url http://mynetwork.com/site1.

What you choose will be partly based on personal preference, but each approach does have its drawbacks:

  • Subdirectories can lead to url clashes if you’re installing Multisite on an existing site. For example you might have already created a blog post at http://mynetwork.com/site1 which would mean a clash. So if you’re working with an existing site, WordPress will normally force you to use subdomains.
  • Subdomains can occasionally cause problems based on your hosting setup. You roosting provider will need to allow wildcard subdomains so that all new sites with their own subdomain will work correctly. Any decent hosting provider will be able to do this for you.

I tend to use subdomains where possible as I find these make things easier when accessing individual sites, but what you choose will be up to you. Your choice will effect the edits you make to your files, so you need to know what option you’re going with.

Editing wp-config.php to Allow a Network

The first step in installing Multisite is to allow it by editing your wp-config.php file. After installing WordPress, open your wp-config.php file and find the following line:

/* That's all, stop editing! Happy blogging. */

Immediately above this line, create a new line that reads:

define( 'WP_ALLOW_MULTISITE', true );

Now save your wp-config.php file.

Network Settings

The next step is done in the dashboard. Go to Tools->Network Setup. You’ll see the Network Setup screen.

  1. If you’re given a choice between subdomains and subdirectories, choose the one you want. Depending on your installation, you may not be given a choice.
  2. Edit the title of your network and the email address of the network administrator, or leave them as they are.
  3. Click Install.

Editing .htaccess and wp-config.php

You’ll now be taken to the Network Install screen:

enabling a multisite network

Open each of your .htaccess and wp-config.php files in turn. Copy the code from the screen and add it to the relevant file, inserting it where the instructions tell you to or overwriting existing code as required.

Editing .htaccess

Make sure you only replace existing WordPress rules, which means keeping the first few and last few lines. This means that your .htaccess file will look something like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ms-demo/
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]
# END WordPress

Editing wp-config.php

Add the text you’re copying to your wp-config.php file without replacing anything else. You should add the new code immediately below the line you added earlier on, which means this section of your file will look something like this:

define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'rachelmccollin.co.uk');
define('PATH_CURRENT_SITE', '/ms-demo/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
/* That's all, stop editing! Happy blogging. */

Now save both of your files.

Return to the dashboard and click the login link on the Network Install screen. After logging in your dashboard will look like this:

the wordpress multisite dashboard

Notice the My Sites link in the admin bar. This means you’ve successfully installed WordPress Multisite. And that’s it!



Posted in Essentials
Tagged , |