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,925
    @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,925
    @feibisi

    單個 WordPress 的獨立規則:

    location / {
        try_files $uri $uri/ /index.php?$args;
        }
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    
    風間
    參與者
    • 文章數量: 670
    @fengjian
    樓主

    github 上的程式碼:

正在檢視 4 個帖子:1-4 (共 4 個帖子)
  • 哎呀,回覆話題必需登入。

話題資訊

  • 當前位於:WordPress Multisite
  • 3 條回覆
  • 2 個參與人
  • 最後回覆:<a href="https://bbs.weixiaoduo.com/users/fengjian/" title=" 檢視風間的個人資料" class="bbp-author-link"><span class="bbp-author-name"> 風間</span></a>
  • 上次活動:<a href="https://bbs.weixiaoduo.com/topic/21391/#post-21395" title=" 回覆至:WordPress + nginx 伺服器的 multisite 多站點模式,偽靜態規則和配置;">8 年、 2 月前</a>