久青草国产观看在线视频,在线观看欧美日女,777毛片,亚洲国产精品99久久久久久久

WordPress nginx多站點rewrite(重寫)規則

2018-08-09 wordpress經驗
  • 文章介紹
  • 快速入門
  • 評價&建議

WordPress多站點模式可以被應用在多種方式上。其中最常用的是在”子目錄”模式或者”二級域名”模式上。

Nginx提供了兩種特殊的指令:”x-accel-redirect”和”map”,使用這兩個指令可以使得WordPress多站點的網絡服務實現偽靜態功能。

WordPress多站點模式可以被應用在多種方式上。其中最常用的是在”子目錄”模式或者”二級域名”模式上。Nginx提供了兩種特殊的指令:”x-accel-redirect”和”map”,使用這兩個指令可以使得WordPress多站點的網絡服務實現偽靜態功能。

WordPress多站點使用子目錄重寫規則

配置中54ux.com修改為自己的站點域名。

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 54ux.com ;

root /var/www/54ux.com/htdocs;

index index.php;

#多站點配置

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/54ux.com/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;

}

#此處可以繼續添加偽靜態規則

}

WordPress多站二級域名重寫規則

配置中54ux.com修改為自己的站點域名。

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 54ux.com *.54ux.com ;

root /var/www/54ux.com/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/54ux.com/htdocs/wp-content/blogs.dir;

access_log off;log_not_found off;expires max;

}

#此處可以繼續添加偽靜態規則

}

備注

“map”部分可以應用于小站點。大站點的多站點應用可以使用 nginx-helper WordPress插件 。

如果想進一步優化WordPress的性能可以使用Nginx的fastcgi_cache,當使用fastcgi_cache配置需要在編譯nginx時加上ngx_cache_purge模塊以及使用WordPress的緩存插件等等

0 0

企業建站推薦正版商業主題,國內專業團隊開發,完善售后,是您不二選擇。

正版主題商店

主題貓WP建站,累計幫助1300+客戶成功建站,為站長提供支持!

立刻開啟你的建站之旅
QQ在線客服

服務熱線

wordpress建站咨詢