#适用于 http://www.v2op.com/blog/ 这样的形式。 #注意将 /data/vhosts/v2op.com/ 修改为你自己的。 #此配置也可使WordPress支持“固定连接”功能,http://blog.v2op.com/2010/02/nginx-settings-for-wordpress-wp-super-cache server { listen 80; server_name www.v2op.com; root /data/vhosts/v2op.com/; index index.html index.htm index.php; location ~ \.php$ { root /data/vhosts/v2op.com/; index index.html index.htm index.php; fastcgi_pass php; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /data/vhosts/v2op.com/$fastcgi_script_name; include fastcgi_params; if ($request_uri ~* \.(swf|png|gif|jpg|css|js)$) { expires 1y; } } location /blog/ { # enable search for precompressed files ending in .gz # nginx needs to be complied using --with-http_gzip_static_module # for this to work, comment out if using nginx from aptitude gzip_static on; # if the requested file exists, return it immediately if (-f $request_filename) { 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 /blog/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 . /blog/index.php last; } } add_header Vary Accept-Encoding; }