WordPress Multisite, Naiba has heard about it many times, recently researched
Naiba's Theme DEMOWhen building this site, the multisite feature was used, so here we record and share the specific steps and methods for setting up WordPress Multisite. For areas not covered in this article, you can refer to
the official documentation。
WordPress Multisite Introduction
Typically, when we build a WordPress site, the conventional steps are: add Shared Hosting, bind domain, upload installation package, create database, install WordPress. For WordPress Multisite (subdirectory mode), it only requires: enabling multisite mode, adding a new site. For subdomain mode multisite, there should be an additional domain binding step. This is also faster than the conventional installation method, suitable for those who need to create multiple sites at once. These multisites share the main site's database, Theme files, and Plugin files. Any resources available on the main site can be used directly by the sub-sites, eliminating the hassle of repeatedly installing Themes and Plugins. At the same time, user data across multisites is interconnected, and for upgrades, only the main site needs to be upgraded, and other sub-sites are upgraded automatically.
WordPress Multisite Setup Tutorial
This article was completed based on WordPress 5.2.
First, add this line of code to the WordPress site configuration file wp-config.php for the site where you want to enable multisite.
define('WP_ALLOW_MULTISITE', true);
Add the code on the line above the comment /* That's all, stop editing! Happy blogging. */. Then refresh the website's Admin Dashboard, and an option to configure the network will appear, as shown in the figure below.

You can choose between subdomain and subdirectory, select according to your needs.
Subdomain means one website corresponds to one domain. Naiba hasn't tested the subdomain form. Also, if you want to bind other domains, you can
refer to this tutorial. Subdirectory is in the form of adding a folder after the current domain, for example, Naiba's Theme DEMO uses one subdirectory to demonstrate one Theme. After installation, you need to copy the following code and add it to the configuration file wp-config.php. Add it on the line below the code added earlier.

Refresh the WordPress Admin Dashboard again, and the site options will appear.
WordPressThe pseudo-static rules for Multisite on Nginx are not provided here; only Apache rules are available. Naiba will share the Nginx pseudo-static rules later.

To add a new site, fill in the corresponding information and add it. If you have Plugins enabled, you need to manually deactivate all Plugins first.

WordPress Multisite Nginx Pseudo-Static Rules
After adding, when we visit the sub-site just added, we will find the webpage layout is misaligned. This is because the pseudo-static rules haven't been added yet. We just need to add the pseudo-static rules.

Currently, the WordPress Multisite Nginx pseudo-static rule used by Naiba is the following
# wordpress固定链接设置
try_files $uri $uri/ /index.php?$args;
# 管理面板添加斜杠
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# 传递上传文件给 wp-includes/ms-files.php
rewrite /files/$ /index.php last;
# 重写多站点 '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}Another rule
#ignored: “-” thing used or unknown variable in regex/rew
rewrite ^/([_0-9a-zA-Z-]+/)?wp-admin$ /$1wp-admin/ permanent;
if (-f $request_filename){
set $rule_2 1;
}
if (-d $request_filename){
set $rule_2 1;
}
if ($rule_2 = "1"){
#ignored: “-” thing used or unknown variable in regex/rew
}
rewrite ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) /$2 last;
rewrite ^/([_0-9a-zA-Z-]+/)?(.*.php)$ /$2 last;
rewrite /. /index.php last;
Comments are closed
The comment function for this article is closed. If you have any questions, please feel free to contact us through other channels.