wordpress nginx多站點rewrite(重寫)規(guī)則
來源:易賢網(wǎng) 閱讀:1543 次 日期:2014-08-27 14:42:26
溫馨提示:易賢網(wǎng)小編為您整理了“wordpress nginx多站點rewrite(重寫)規(guī)則”,方便廣大網(wǎng)友查閱!

wordpress多站點模式可以被應(yīng)用在多種方式上。其中最常用的是在"子目錄"模式或者"二級域名"模式上。

Nginx提供了兩種特殊的指令:"x-accel-redirect"和"map",使用這兩個指令可以使得wordpress多站點的網(wǎng)絡(luò)服務(wù)實現(xiàn)偽靜態(tài)功能。

wordpress多站點模式可以被應(yīng)用在多種方式上。其中最常用的是在"子目錄"模式或者"二級域名"模式上。Nginx提供了兩種特殊的指 令:"x-accel-redirect"和"map",使用這兩個指令可以使得wordpress多站點的網(wǎng)絡(luò)服務(wù)實現(xiàn)偽靜態(tài)功能。

wordpress多站點使用子目錄重寫規(guī)則

配置中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;

}

#此處可以繼續(xù)添加偽靜態(tài)規(guī)則

}

wordpress多站二級域名重寫規(guī)則

配置中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;

}

#此處可以繼續(xù)添加偽靜態(tài)規(guī)則

}

備注

"map"部分可以應(yīng)用于小站點。大站點的多站點應(yīng)用可以使用 nginx-helper wordpress插件 。

如果想進一步優(yōu)化wordpress的性能可以使用Nginx的fastcgi_cache,當(dāng)使用fastcgi_cache配置需要在編譯nginx時加上ngx_cache_purge模塊以及使用wordpress的緩存插件等等

更多信息請查看IT技術(shù)專欄

更多信息請查看網(wǎng)絡(luò)編程
易賢網(wǎng)手機網(wǎng)站地址:wordpress nginx多站點rewrite(重寫)規(guī)則
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報警專用圖標(biāo)