本站ningx wordpress rewrite重写规则
Author:gaojinbo
Time:2009-11-27
为了让搜索引擎更友好,改变了默认的wordpress链接方式,代码从网上找了很久,测试通过
特发上来与大家分享!
vi 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;
}
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
在server配置中插入以上代码即可!
完成!
十一月 28th, 2009 at 16:36
学习了!嘿嘿!
一月 8th, 2010 at 23:34
复制代码了,回去也这样改
六月 17th, 2011 at 03:16
Related Websites…
[...]some other related resources on the web that are worth viewing on this subject include[...]…