
Want to use W3 Total Cache’s Minify on your WordPress blog which runs on NginX? No problemo. I faced the same problem at first but couldn’t find much info digging around, so I decided to take a look at W3 Total Cache’s rewrite rules and took some time to write them for my NginX configuration.
Note: I’m using Memcached in my minify settings.
Here’s a snippet from my NginX configuration:
server {
listen 80;
access_log /var/www/example.com/log/access.log;
error_log /var/www/example.com/log/error.log notice;
server_name example.com;
root /var/www/example.com/public_html;
rewrite ^/wp-content/w3tc/min/([a-f0-9]+)\/(.+)\.(include(\-(footer|body))?(-nb)?)\.[0-9]+\.(css|js)$ /wp-content/w3tc/min/index.php?tt=$1&gg=$2&g=$3&t=$7 last;
...*more NginX config stuff*
}
For the Minify rewrite to work, you must add the following line after in server{} block:
rewrite ^/wp-content/w3tc/min/([a-f0-9]+)\/(.+)\.(include(\-(footer|body))?(-nb)?)\.[0-9]+\.(css|js)$ /wp-content/w3tc/min/index.php?tt=$1&gg=$2&g=$3&t=$7 last;
Make sure that your WordPress root is set to the correct directory otherwise the Minify rewrite will not work.
{ 2 comments… read them below or add one }
Can you tell exactly where to place that code? I am unable to get the permalinks to work
I pasted the code above in my vhosts file.
What’s confusing is your “…*more NginX config stuff*” in there. Should we put the code there? or where you put it above?
P. S. I am using APC and the latest version of wordpress 3.05. Not sure if that makes a difference.