本站web服务器用的是Nginx,所以无法启用WP Super Cach的mod_rewrite,我们依然可以通过配置规则来达到mod_rewrite实现的效果。
在虚拟主机的.conf文件中增加一个location节点:
[code]
location / {
if (-f $request_filename) {
break;
}
set $supercache_file ”;
set $supercache_uri $request_uri;
set $supercache 1;
set $ihttp_host ”;
if ($request_method = POST) {
set $supercache 0;
}
set $qs 0;
if ($query_string) {
set $qs 1;
}
if ($query_string ~* "^utm_source=([^&]+)&utm_medium([^&]+)&utm_campaign=([^&]+)(&utm_content=([^&]+))?$") {
set $qs 0;
set $supercache_uri $document_uri;
}
if ($qs = 1) {
set $supercache 0;
}
# 针对已登录用户(发表过评论),可以不静态化。在访问量高峰时可注释掉
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
set $supercache 0;
}
#结束
if ($http_user_agent ~* ‘(iphone|ipod|aspen|incognito|webmate|android|dream|cupcake|froyo|blackberry9500|blackberry9520|blackberry9530|blackberry9550|blackberry 9800|webos|s8000|bada)’) {
set $ihttp_host ‘-mobile';
}
if ($supercache = 0) {
set $supercache_uri ”;
}
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /wp-content/cache/supercache/$http_host$1/index${ihttp_host}.html;
}
if (-f $document_root$supercache_file) {
#rewrite ^(.*)$ $supercache_file break;
rewrite ^ $supercache_file last;
}
if (!-e $request_filename) {
rewrite . /index.php last;
}
}
[/code]
相关WP Super Cach使用教程请继续关注!