简体   繁体   English

NGINX 设置 WordPress 多站点

[英]NGINX Setup with WordPress Multisite

I wanted to know the configuration for WordPress Multisite when the main site is in the root and the others in /site-name/我想知道 WordPress 多站点的配置,当主站点在根目录中,其他站点在 /site-name/

For example:例如:

Main website: http://www.example.com/ Second website: http://www.example.com/second-site/ Third site: http://www.example.com/thrid-site/

I looked for the setting, but I only found it with subdomains.我寻找设置,但我只找到了子域。

Let's say your folder structure is as follows:假设您的文件夹结构如下:

/root_folder/*
/root_folder2/second-site/*
/root_folder3/third-site/*

Then you need:那么你需要:

server {
    server_name www.example.com;
    
    root /root_folder/;
    
    location / {
        # code
    }
    
    location /second-site {
        root /root_folder2/;
        # code
    }

    location /third-site { 
        root /root_folder3/;
        # code
    }
}

It's important not to add the /second-site and /third-site in the root directive as Nginx will automatically add requested subpaths to the root path at request.重要的是不要在根指令中添加 /second-site 和 /third-site,因为 Nginx 会根据请求自动将请求的子路径添加到根路径。

If your folder structure is as follows:如果你的文件夹结构如下:

/root_folder/*
/root_folder/second-site
/root_folder/third-site

You only need你只需要

server {
    server_name www.example.com;

    root /root_folder/;

    location / {
        # code
    }
}

And Nginx will do the rest for you. Nginx 将为您完成 rest。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM