wordpress-multisite-with-subdirectories-2.png

How to Setup WordPress Multisite with subdirectories

This post will guide you on how to set 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.

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!

Setting-up WordPress Multisite with subdirectories in just five steps.

1 Starting from a standard WordPress site.

WARNING: Do not experiment with your production site! period and backups. Work with a clone, or launch a clean WordPress site. Both options take a few seconds to launch with Wetopi Specialized Managed Hosting (watch this 20sec video Stop breaking your live WordPress).

If your hosting does not provide staging server,
invest 10 secs and!
Sign up to get your FREE development servers now

Once you have a standard WordPress site up and running, we are ready to enable the WordPress Multisite with subdirectories mode.

2 Enabling 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:

We will log to enable WordPress Multisite with subdirectories using the sftp credentials
Credentials in your wetopi server “Options Menu”

Editing wp-config.php

This capture of an SFTP client shows the wp-config.php file inside the html dir:

Sftp WordPress html dir content
This SFTP client shows where you can find the wp-config.php file

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.

3 Network 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):

Once enabled WordPress Multisite with subdirectories our Tools menu shows the Network setup

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.

4 Enabling the 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
Nginx! it doesn’t have .htaccess!

we have a different config.

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:

Nginx config to edit in order to Setup WordPress Multisite with sub-directories
To Setup WordPress Multisite with subdirectories, you have to edit the Nginx config.

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

5 Loading our 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:

Reload nginx config

Go back to your WordPress Dashboard. Now you should see the new “My sites” section:

Once enabled WordPress Multisite with subdirectories our dashboard shows the My Sites section

Now, the WordPress Multisite with subdirectories feature has been fully enabled and configured.

Go to the dashboard and create your sites.

At wetopi, we want to minimize the friction that every professional face when working and hosting WordPress projects.

In short, we are just techies passionate about WordPress. With wetopi, a specialized WordPress hosting, we want to go further to offer professionals and agencies a platform to work efficiently and effectively.

Not a wetopi user?

Try now – you'll find an efficient way to work with WordPress

Free full performance servers for your development and test.
No credit card required.


1 Star2 Stars3 Stars4 Stars5 Stars (19 votes, average: 4.63 out of 5)
Loading...
Carlos PortilloHow to Setup WordPress Multisite with subdirectories
Share this post