🚀 Is building a website too difficult? Let me guide you step by step—Learn about the 「Naibabiji WordPress Website Building Coaching Service」 →

WordPress Multisite Setup Tutorial with Screenshots (Including Pseudo-static Rules)

WordPress Multisite, Naiba has heard about it many times, recently researchingNaiba'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 tothe official documentation.

Introduction to WordPress Multisite

Typically, when we build a WordPress site, the conventional steps are: add a virtual host, bind a domain, upload the installation package, create a 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 subsites, eliminating the hassle of repeatedly installing themes and plugins. At the same time, user data across multisites is interconnected, and upgrades only require upgrading the main site, after which other subsites are automatically upgraded.

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);
WordPress多站点教程Add the code on the line above the comment /* That's all, stop editing! Happy blogging. */. Then refresh the website admin dashboard, and an option to configure the network will appear, as shown in the image below.WordPress多站点教程
You can choose between subdomains and subdirectories, 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 canrefer to this tutorial. Subdirectory is in the form of a folder appended to the current domain, for example, Naiba's Theme DEMO uses a subdirectory to demonstrate each 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.WordPress多站点教程Refresh the WordPress admin dashboard again, and the Sites option will appear.WordPressThe pseudo-static rules for Nginx for multisite are not provided here; only Apache rules are given. Naiba will share the Nginx pseudo-static rules later.WordPress多站点教程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多站点教程

WordPress Multisite Nginx Pseudo-Static Rules

After adding, when we visit the newly added subsite, 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.WordPress多站点教程Currently, the WordPress Multisite Nginx pseudo-static rule Naiba uses is the following one.
# 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;

🚀 Still feeling confused after reading the tutorial? Let me guide you step-by-step.

「Naibabiji WordPress Website Building Coaching Service」—From choosing a domain and buying hosting, to installing a Theme and publishing content, I「ll coach you through every step, helping you avoid detours and reach your goal directly.

👉 Learn about the Website Building Coaching Service
🔒

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.

×
二维码

Scan QR Code to Follow

AI Website Building Assistant

🤖
Hello! I am the Naibabiji AI Assistant. How can I help you?
Quick Consultation: