|
楼主 |
发表于 2009-8-26 17:43:41
|
显示全部楼层
找到了解决方法.可是我不懂怎么新建文件,怎么在nginx配置文件中include这个文件,重新load配置?请高手指点.
我用wordpress super cache和nginx来加速wp博客网页,由于需要使用wordpress permalink,需要为wordpress建立一个nginx的rewrite规则, 参照了wordpress super cache作者博客中的一篇评论,具体操作方法如下,首先新建一个文件your_nginx_path/conf/wp_rewrite.conf, 建立如下:
if (-f $request_filename) {
expires 7d;
break;
}
set $supercache_file ”;
set $supercache_uri $request_uri;
if ($request_method = POST) {
set $supercache_uri ”;
}
# Using pretty permalinks, so bypass the cache for any query string
if ($query_string) {
set $supercache_uri ”;
}
if ($http_cookie ~* “comment_author_|wordpress|wp-postpass_” ) {
set $supercache_uri ”;
}
# if we haven’t bypassed the cache, specify our supercache file
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
}
# only rewrite to the supercache file if it actually exists
if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}
# all other requests go to Wordpress
if (!-e $request_filename) {
rewrite . /index.php last;
}
然后在你的nginx配置文件中include这个文件,重新load配置即可。 |
|