正在加载...

Nginx的WordPress rewrite规则:

注:可以直接写在nginx.conf里;也可以新建为wordpress.conf,然后include进nginx.conf里。

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;
}

WordPress SuperCache rewrite规则:

注:可以直接写在nginx.conf里;也可以新建为supercache.conf,然后include进nginx.conf里。

location /
{
autoindex off;
gzip_static on;
set $wp_super_cache_file ”;
set $wp_super_cache_uri $request_uri;
if ( $request_method = POST )
{
set $wp_super_cache_uri ”;
}
if ( $query_string )
{
set $wp_super_cache_uri ”;
}
if ( $http_cookie ~* “comment_author_|wordpress|wp-postpass_” )
{
set $wp_super_cache_uri ”;
}
if ( $wp_super_cache_uri ~ ^(.+)$ )
{
set $wp_super_cache_file /wp-content/cache/wp_super_cache/$http_host/$1index.html;
}
if ( -f $document_root$wp_super_cache_file )
{
rewrite ^(.*)$ $wp_super_cache_file break;
}
if (-f $request_filename)
{
expires 30d;
break;
}
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php?q=$1 last;
}
}

: http://www.ha97.com/915.html

本文相关评论 - 才 3 条评论
南柯一梦
2010-07-09 00:21:55
TheWorld Browser TheWorld Browser Windows Vista Windows Vista

Nginx的WordPress rewrite规则
这个应该是适用于根目录下的WordPress程序
如果我是在/blog/目录下使用WordPress的,rewrite规则应该怎么写?

2010-07-09 00:27:25
Minefield 4.0b2pre Minefield 4.0b2pre Windows Vista Windows Vista

修改相应的路径就可以了。/改为/blog

2010-07-26 03:18:59
WordPress 2.9.2 WordPress 2.9.2

[…] Nginx的WordPress rewrite和WordPress SuperCache rewrite规则 wordpress在nginx下的配置包含supercache支持 WP Super Cache使用全攻略 […]