文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>自动转换rewrite rule 从Apache .htaccess到ngin..

自动转换rewrite rule 从Apache .htaccess到ngin..

时间:2010-08-10  来源:cyema

地址如下:http://oox.bz/6C

转换速度非常快,效果很好,比如,我将supercache的.htaccess:

# BEGIN WPSuperCache

RewriteEngine On
RewriteBase /
AddDefaultCharset UTF-8
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP_USER_AGENT} !^.*(2.0 MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo Wii|Nitro|Nokia|Opera Mini|Palm|PlayStation Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows CE|WinWAP|YahooSeeker/M1A1-R2D2||iPod|Android|BlackBerry9530|LG-TU915 Obigo|LGE VX|webOS|Nokia5800).*
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]

RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.*
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{HTTP_USER_AGENT} !^.*(2.0 MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo Wii|Nitro|Nokia|Opera Mini|Palm|PlayStation Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915 Obigo|LGE VX|webOS|Nokia5800).*
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]

# END WPSuperCache

转换后得到:

if ($request_method !~ “POST”){
set $rule_0 1$rule_0;
}
if ($args !~ “.*=.*”){
set $rule_0 2$rule_0;
}
if ($http_cookie !~ “^.*(comment_author_|wordpress|wp-postpass_).*$”){
set $rule_0 3$rule_0;
}
#ignored: condition 3
if ($http_accept_encoding ~ “gzip”){
set $rule_0 5$rule_0;
}
if (-f $document_root/wp-content/cache/supercache/$http_host/$1/index.html.gz){
set $rule_0 6$rule_0;
}
if ($rule_0 = “65421″){
rewrite ^/(.*) /wp-content/cache/supercache/$http_host/$1/index.html.gz last;
}
if ($request_method !~ “POST”){
set $rule_1 1$rule_1;
}
if ($args !~ “.*=.*”){
set $rule_1 2$rule_1;
}
if ($http_cookie !~ “^.*(comment_author_|wordpress|wp-postpass_).*$”){
set $rule_1 3$rule_1;
}
#ignored: condition 3
if (-f $document_root/wp-content/cache/supercache/$http_host/$1/index.html){
set $rule_1 5$rule_1;
}
if ($rule_1 = “5421″){
rewrite ^/(.*) /wp-content/cache/supercache/$http_host/$1/index.html last;
}

可以看到,效果是十分不错的。推荐使用。

放http://www.petyoo.com/petlist.php 这个站的VPS就用的nginx 伪静态

相关阅读 更多 +
排行榜 更多 +
幸运硬币官方正版下载

幸运硬币官方正版下载

休闲益智 下载
宝宝来找茬手机版 v9.86.00.00 安卓版

宝宝来找茬手机版 v9.86.00.00 安卓版

休闲益智 下载
翻滚飞机大战最新版 v1.0.4 安卓版

翻滚飞机大战最新版 v1.0.4 安卓版

飞行射击 下载