本站ningx wordpress rewrite重写规则

十一月 27th, 2009 Posted in Nginx | 阅读次数: 299 次

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配置中插入以上代码即可!

 

完成!

相关日志:

3 Responses to “本站ningx wordpress rewrite重写规则”

  1. 老潘 Says:

    学习了!嘿嘿!


  2. 如何快速去痘印 Says:

    复制代码了,回去也这样改


  3. cure panic attacks Says:

    Related Websites…

    [...]some other related resources on the web that are worth viewing on this subject include[...]…


留下您的脚印