自动转换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 伪静态