This post will walk you through setting up a WordPress Multisite with subdirectories so you can manage multiple sites under different paths. e.g. site.com/support/
and site.com/eu/
etc.
Table of Contents
Setting-up WordPress Multisite with subdirectories in just five steps
Still haven’t made the decision to utilize sub-domains, subdirectories or even multisite? Take a look at this compendium of Conditionals and a list of Good and Bad Parts, to definitively help you to decide.
Hands-on Guide!
1Start from a standard WordPress site
WARNING: Do not experiment with your production site!
Work in a Staging clone, or launch a clean WordPress site. Both options take a few seconds to launch with Wetopi Specialized Managed Hosting (watch this 20sec video that shows how to Stop breaking your live WordPress).
If your hosting does not provide a Staging server,
invest 10 secs and:
Sign up to get your FREE development server now!
Once you have a standard WordPress site up and running, we are ready to enable the WordPress Multisite with subdirectories mode.
2Enable Multisite mode
To do this, you need to modify the WordPress configuration: wp-config.php
Log into your server using an ftp client and open the wp-config.php with your favorite text editor.
At wetopi, we use secure SFTP, which is the same as ftp but the connection is secure and information travels encrypted. If you are running a wetopi server, you’ll find the SFTP credentials in the Options menu → Advanced section of your Wetopi WordPress server:
Edit wp-config.php
This capture of an SFTP client shows the wp-config.php
file inside the html dir:
Once opened with your text editor, locate the bit that says:
/* That's all, stop editing! Happy blogging. */
And above the line shown above, add the following lines shown below:
/** Multisite */
define('WP_ALLOW_MULTISITE', true);
Done!
Once saved, Go back to your WordPress to enable the Network.
3Network Setup
Go back to your WordPress and reload the admin page. Now you will find a new menu item, the “Network Setup” (under the Tools menu):
Now, in the Network Setup section, you have the choice to install Multisite to work with Subdomains or Subdirectories. For the tutorial purpose, we will check the Subdirectories option. Optionally you can name the network websites. Then, click on the Install button.
4Enable the WordPress Network
After clicking the “Install” button, WordPress will generate configuration lines in wp-config.php
and .htaccess
Step 1. Add the following to your wp-config …
Let’s go back to the wp-config.php
, and add the prompted lines shown in step 1:
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'yourdomain.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
This is what we ended up having in our wp-config.php
:
/** Multisite */
define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'yourdomain.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
/* That's all, stop editing! Happy blogging. */
Step 2. Editing your webserver config
If you run your WordPress site with Apache web server, go back to the SFTP client and edit the .htaccess
file.
NOTE: You’ll find the .htaccess
in the same path you found the previous wp-config.php
Wait! At Wetopi, we are using the incredibly fast Nginx but
we have a different config.
Nginx! it doesn’t have.htaccess
!
Let’s go back to our SFTP and instead of editing the .htaccess we will edit our nginx.conf
At Wetopi you’ll find the nginx.conf
file in the /var/www/conf
dir:
Once opened with our editor, locate the bit that says:
location / {
include /var/www/conf/mime.types;
# No php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
And above, add (or uncomment) the following lines:
# Multisite subdirectory mode only (subdomains mode works by default)
# uncomment following if-block only if you are running a WordPress multisite under subdirectories
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(?!^/my-db-admin)(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(?!^/my-db-admin)(/[^/]+)?(/.*.php) $2 last;
}
This is how it will look like at the end:
location = /robots.txt {
allow all;
try_files $uri /index.php?$args;
}
location / {
include /var/www/conf/mime.types;
# No php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
# Multisite subdirectory mode only (subdomains mode works by default)
# uncomment following if-block only if you are running a WordPress multisite under subdirectories
#
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(?!^/my-db-admin)(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(?!^/my-db-admin)(/[^/]+)?(/.*.php) $2 last;
}
5Loading the new server config
Once, changes in the nginx.conf
(or .htaccess
) are saved, your server has to load the new config. If you are running a Wetopi server, this is a simple click: go to your Options menu and click the Reload button:
Go back to your WordPress Dashboard. Now you should see the new “My sites” section:
Now, the WordPress Multisite with subdirectories feature has been fully enabled and configured.
Go to the dashboard and create your sites.
Don’t you have an account on Wetopi?
Free full performance servers for your development and test.
No credit card required.