Hey there,
I recently switched from a subdomain to subdirectory install, and can’t seem to get the minification working on the sub blog (example.com/site2/). Everything else works perfectly fine on the main site. Here’s my Nginx config:
server {
listen 80;
server_name www.example.com;
return 301 http://example.com$request_uri;
}
server {
listen 80;
root /var/www/example.com/public_html;
index index.php index.html index.htm;
server_name example.com *.example.com;
##
# Access and error log locations
##
access_log off;
error_log /var/log/nginx/example.com.error.log;
##
# Global Configurations/Restrictions
##
# Global PHP include
include conf.d/global/php.conf;
# Global restrictions
include conf.d/global/restrictions.conf;
# W3 Total Cache
include conf.d/w3totalcache/example.com.conf;
# WordPress multisite subdirectory
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
}
The includes, to keep things neat:
include conf.d/global/php.conf
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.socket;
fastcgi_index index.php;
include fastcgi_params;
}
# Allow cross origin fonts
location ~* \.(eot|otf|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
include conf.d/global/restrictions.conf;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ /\. {
deny all;
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
And the last would be the one that W3TC writes to, which works fine.
Which rules am I missing to enable the minification of CSS/JS in example.com/site2/?
When using the subdomain variation, the above rules were the same except for the rewrites, I believe, and things kind of worked. It minified and output the files, but also didn’t remove copies of the theme’s assets, so everything was duplicated. But that’s not the issue here, sorry.
I’ve tried using your tutorial here, but changed back because I had the same issue: https://rtcamp.com/wordpress-nginx/tutorials/multisite/subdirectories/w3-total-cache/
Thanks for any feedback you might be able to provide.