Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to enable multi-site support and rewrite rule configuration of Nginx in WordPress

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Today, I would like to share with you how to enable multi-site support and Nginx rewriting rules configuration in WordPress related knowledge points, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you can learn something after reading this article, let's take a look at it.

Multiple sites can be used directly in wordpress3.0 and above, and it can:

1. Only one wordpress program can be installed to create multiple wordpress sites, which can be subdomain names or subdirectories.

2. There can be independent blog backstage and independent blog address.

3. The administrator can set which topics are open to the site.

4. The administrator can configure the plug-in for each site.

5. "user database tables" are shared among multiple sites, that is, tables wp_usermeta and wp_users, and the rest are independent database tables.

Wordpress multi-site configuration method:

1. First of all, back up the database of the website in case of accident (generally negligible).

2. Open the wp-config.php file in the root directory of wordpress, and in the

Require_once (abspath. 'wp-settings.php')

Precede with the following code:

Define ('wp_allow_multisite',true)

3. Enter the wordpress backend, click "tools"-> "configure Network"

Ps: if you want to use the form of a second-level domain name, you can go to Settings-> General, and put the www of the site address (url). Get rid of it.

4. After clicking install, follow the prompts to make the relevant configuration.

5. Once configured, enter the background again, and the option menu of "my site"-> "manage Network" will appear in the head. then you can manage or create a site, or open a theme or plug-in for other sites to use.

6. If you want to bind another domain name to the site, you can install the wordpress mu domain mapping plug-in.

Nginx multi-site rewrite (rewrite) rules

The wordpress multi-site model can be applied in many ways. One of the most commonly used is in "subdirectory" mode or "second-level domain name" mode.

Nginx provides two special instructions: "x-accel-redirect" and "map", which can be used to enable wordpress multi-site network services to implement pseudo-static functions.

Wordpress multisite uses subdirectory rewriting rules:

The jb51.net in the configuration is modified to its own site domain name.

Map $uri $blogname {~ ^ (? P / [^ /] + /) files/ (. *) $blogpath;} map $blogname $blogid {default-999; # ref: http://wordpress.org/extend/plugins/nginx-helper/ # include / var/www/wordpress/wp-content/plugins/nginx-helper/map.conf;} server {server_name jb51.net; root / var/www/jb51.net/htdocs; index index.php # Multi-site configuration location ~ ^ (/ [^ /] + /)? files/ (. +) {try_files / wp-content/blogs.dir/$blogid/files/$2 / wp-includes/ms-files.php?file=$2; access_log off; log_not_found off; expires max;} # avoid php readfile () location ^ ~ / blogs.dir {internal; alias / var/www/jb51.net/htdocs/wp-content/blogs.dir; access_log off; log_not_found off; expires max } if (!-e $request_filename) {rewrite / wp-admin$ $scheme://$host$uri/ permanent; rewrite ^ (/ [^ /] +)? (/ wp-.*) $2 last; rewrite ^ (/ [^ /] +)? (/. *\ .php) $2 last;} location / {try_files $uri $uri/ / index.php?$args;} location ~\ .php$ {try_files $uri = 404; include fastcgi_params; fastcgi_pass php } # you can continue to add pseudo-static rules here}

Wordpress multi-site second-level domain name rewriting rules:

The jb51.net in the configuration is modified to its own site domain name.

Map $http_host $blogid {default-999; # ref: http://wordpress.org/extend/plugins/nginx-helper/ # include / var/www/wordpress/wp-content/plugins/nginx-helper/map.conf;} server {server_name jb51.net *. Jb51.net; root / var/www/jb51.net/htdocs; index index.php; location / {try_files $uri $uri/ / index.php?$args;} location ~\ .php$ {try_files $uri = 404; include fastcgi_params Fastcgi_pass php;} # wpmu files location ~ ^ / files/ (. *) ${try_files / wp-content/blogs.dir/$blogid/$uri / wp-includes/ms-files.php?file=$1; access_log off; log_not_found off; expires max;} # wpmu x-sendfile to avoid php readfile () location ^ ~ / blogs.dir {internal; alias / var/www/jb51.net/htdocs/wp-content/blogs.dir; access_log off; log_not_found off; expires max } # you can continue to add pseudo-static rules here}

Remarks

The "map" section can be applied to small sites. Nginx-helper wordpress plug-ins can be used for multi-site applications with large sites.

If you want to further optimize the performance of wordpress, you can use nginx's fastcgi_cache. When using fastcgi_cache configuration, you need to add ngx_cache_purge modules and cache plug-ins that use wordpress when compiling nginx.

These are all the contents of the article "how to enable multi-site support and Nginx rewriting rule configuration in WordPress". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report