这个规则是本人亲自在华夏名网虚拟主机测试使用成功的wordpress WP-Super-Cache nginx重写规则,希望各位wordpress爱好者能够用得上,在这里贴出来也方便以后自己查找。
# WP Super Cache rules. # Designed to be included from a 'wordpress-ms-...' configuration file. # Enable detection of the .gz extension for statically compressed content. # Comment out this line if static gzip support is not compiled into nginx. gzip_static on; set $supercacheuri ""; set $supercachefile "$document_root/wp-content/cache/supercache/${http_host}${uri}index.html"; if (-e $supercachefile) { set $supercacheuri "/wp-content/cache/supercache/${http_host}${uri}index.html"; } # If this is a POST request, pass the request onto WordPress. if ($request_method = POST) { set $supercacheuri ""; } # If there is a query string, serve the uncached version. if ($query_string) { set $supercacheuri ""; } # Logged in users and those who have posted a comment get the non-cached version. if ($http_cookie ~* comment_author_|wordpress_logged_in|wp-postpass_) { set $supercacheuri ""; } # Mobile browsers get the non-cached version. # Wastes CPU cycles if there isn't a mobile browser WP theme for the site. if ($http_x_wap_profile) { set $supercacheuri ""; } if ($http_profile) { set $supercacheuri ""; } if ($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)) { set $supercacheuri ""; } if ($http_user_agent ~* (w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-)) { set $supercacheuri ""; } # Stop processing if the supercache file is valid. if ($supercacheuri) { rewrite ^ $supercacheuri break; }