Nginx also supports URL rewrite, not compatible to Apache’s mod_rewrite, but more intuitive and more powerful imho. The only problem is most applications, WordPress and ZenPhoto for this specific case do include the mod_rewrite code snippet and/or may update the .htaccess for your convenience.
Thanks to the Slicehost community, the port of mod_rewrite rules perfectly covers WordPress and SuperCache. Here are some minor modification to craft for more general usage:
# the blog dir, aka where index.php is set $blog\_dir ''; # the wordpress dir where all wp-* stays set $wordpress\_dir '/wordpress'; include wordpress.rewrite;
In nginx.conf, define wordpress_dir and blog_dir, these two variables are equivalent to WordPress address (URL) and Blog address (URL) stripped off the host information. Then we can replace the hard-coded /blog path by using
2d1 < 26c25 < set $supercache_file /blog/wp-content/cache/supercache/$http_host/$1index.html; --- > set $supercache_file $wordpress_dir/wp-content/cache/supercache/$http_host/$1index.html; 36c35 < rewrite . /blog/index.php last; --- > rewrite ^(.*)$ $blog_dir/index.php?q=$1 last;