WordPress + nginx 服务器的 multisite 多站点模式,伪静态规则和配置;

WordPress + nginx 服务器的 multisite 多站点模式,伪静态规则和配置;

正在查看 4 个帖子:1-4 (共 4 个帖子)
  • 作者
    帖子
  • 风间
    参与者
    • 文章数量: 670
    @fengjian
    楼主

    找了半天才算是找到了最合适的伪静态规则文件,有必要贴上来方便以后查阅,服务器是全新配置的,现在终于算是可以正常使用了,以下规则为 WordPress + nginx 服务器的 multisite 多站点模式,伪静态规则和配置;

    仅供参考,如有需要请按照你自己的站点具体配置进行域名和路径的修改。

    
    server {
      listen 80;
      server_name www.weixiaoduo.com *.weixiaoduo.com 
      access_log /data/wwwlogs/www.weixiaoduo.com_nginx.log combined;
      index index.html index.htm index.php;
      root /data/wwwroot/www.weixiaoduo.com;
    
      location ~ [^/]\.php(/|$) {
        #fastcgi_pass remote_php_ip:9000;
        fastcgi_pass unix:/dev/shm/php-cgi.sock;
        fastcgi_index index.php;
        include fastcgi.conf;
      }
      location / {
          index index.php;
          try_files $uri $uri/ /index.php?$args;
      }
    
      # Add trailing slash to */wp-admin requests.
      rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    
      # Directives to send expires headers and turn off 404 error logging.
      location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
          expires 24h;
          log_not_found off;
      }
    
      # this prevents hidden files (beginning with a period) from being served
          location ~ /\.          { access_log off; log_not_found off; deny all; }
    
      # Pass uploaded files to wp-includes/ms-files.php.
      rewrite /files/$ /index.php last;
    
      if ($uri !~ wp-content/plugins) {
          rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
      }
    
      # Rewrite multisite '.../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;
      }
    
    }
    
    诗语
    管理员
    • 文章数量: 5,910
    @feibisi

    备用的,但是发现有些小问题,还是留存下:

    
      # Add trailing slash to */wp-admin requests.
      rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    
      # Directives to send expires headers and turn off 404 error logging.
      location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
          expires 24h;
          log_not_found off;
      }
    
      # this prevents hidden files (beginning with a period) from being served
          location ~ /\.          { access_log off; log_not_found off; deny all; }
    
      # Pass uploaded files to wp-includes/ms-files.php.
      rewrite /files/$ /index.php last;
    
      if ($uri !~ wp-content/plugins) {
          rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
      }
    
      # Rewrite multisite '.../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;
      }
    
    诗语
    管理员
    • 文章数量: 5,910
    @feibisi

    单个 WordPress 的独立规则:

    location / {
        try_files $uri $uri/ /index.php?$args;
        }
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    
    风间
    参与者
    • 文章数量: 670
    @fengjian
    楼主

    github 上的代码:

正在查看 4 个帖子:1-4 (共 4 个帖子)
  • 哎呀,回复话题必需登录。

话题信息