Daniel
Daniel

Reputation: 41

W3 Total Cache minify rewrite rules not working with nginx

I have setup a WordPress installation with W3 Total Cache on a nginx server. I am using the minify option with Opcode APC and automatic mode. I am receiving the following error after activating this option:

It appears Minify URL rewriting is not working. If using apache, verify that the server configuration allows .htaccess or if using nginx verify all configuration files are included in the configuration.

In nginx.conf I have what the plugin suggested me to put, namely this:

# BEGIN W3TC Minify core
rewrite ^/usr/share/nginx/html/wp-content/w3tc/min/w3tc_rewrite_test$ /usr/share/nginx/html/wp/wp-content/w3tc/min/index.php?w3tc_rewrite_test=1 last;
rewrite ^/usr/share/nginx/html/wp-content/w3tc/min/(.+\.(css|js))$ /usr/share/nginx/html/wp/wp-content/w3tc/min/index.php?file=$1 last;
# END W3TC Minify core

Above this rule I also have the following to enable WordPress pretty permalinks:

try_files $uri $uri/ /index.php;

and this to prevent zero-day exploits:

#try_files      $uri =404;

However disabling these still don't make minify rewrites work.

If I disable the URL rewriting for minify, the request returns a 400 status.

Any idea what I may be doing wrong?

Upvotes: 1

Views: 8125

Answers (2)

doublesharp
doublesharp

Reputation: 27657

There is a missing configuration for Nginx that is include in the Apache configuration via an .htaccess file. In my case rewriting was working, but I was getting the error message above using file, APC, and Memcached minification. After digging around the code a bit, I added this line to my Nginx configuration and it cleared up the message:

rewrite /w3tc_rewrite_test$ /wp-content/plugins/w3-total-cache/pub/minify.php?w3tc_rewrite_test=1 permanent;

You can also include the nginx.conf that the plugin generates in your root folder.

http://justinsilver.com/technology/fixed-appears-minify-url-rewriting-working-w3tc-nginx/

Upvotes: 1

rahul286
rahul286

Reputation: 949

You don't need to put those lines in nginx config as suggested by plugin.

Here is an updated config - http://rtcamp.com/tutorials/standard-wordpressnginx-configuration-w3-total-cache/

It might make way into W3 Total Cache help section (see comments on above article for ref)

Upvotes: 1

Related Questions