Nginx is becoming more and more popular because of its high performance, I will show you how to create WordPress rewrite rule for nginx.
Suppose you install WordPress under /blog/ directory.
Without WP Super Cache plugin
location /blog {
try_files $uri $uri/ /blog/index.php?q=$uri&$args;
}
With WP Super Cache plugin installed
location /blog/ {
if (-f $request_filename) {
break;
}
set $supercache_file ”;
set $supercache_uri $request_uri;
if ($request_method = POST) {
set $supercache_uri ”;
}
if ($query_string) {
set $supercache_uri ”;
}
if ($http_cookie ~* “comment_author_|wordpress|wp-postpass_” ) {
set $supercache_uri ”;
}
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /blog/wp-content/cache/supercache/$http_host/$1index.html;
}
if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}
if (!-e $request_filename) {
rewrite . /blog/index.php last;
}
}
Isn’t it pretty easy? Happy blogging, happy high performance.
RSS Feed
Posted in
Tags: