需要 Nginx 专家(Wordpress 插件问题)

Need Nginx Expert (Wordpress plugin issue)

我是 运行 一个 nginx 上的 wordpress 网站,除了我的一个插件 = Adaptive Images for WordPress 之外,一切都像魅力一样。 (此插件提供缩放图像)。

这个插件的所有者说,将它添加到位置但它不起作用。

location / {
rewrite \.(?:jpe?g|gif|png)$ /wp-content/plugins/adaptive-images/adaptive-images-script.php;
}

也试过这个:

location ~ /wp-content/(themes|uploads) {
     rewrite \.(?:jpe?g|gif|png)$ /wp-content/plugins/adaptive-images/adaptive-images-script.php;
}

还有这个:

location ~ /wp-content/(themes|uploads) {
rewrite \.(?:jpe?g|gif|png)$ /wp-content/plugins/adaptive-images/adaptive-images-script.php;

}

没有任何效果!

这是我的 nginx 配置:https://github.com/stonedb00/stonedb/blob/master/nginxconf

所以我需要一个 nginx 专家给我正确的重写配置并解决它!

提前致谢

你的错误是你所有的图像请求都是由 nginx 处理的 location 块:

location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
    expires               60d;
    log_not_found         off;
}

由于您要使用插件处理所有图像请求,请尝试以下配置:

location / {
    rewrite \.(?:jpe?g|gif|png)$ /wp-content/plugins/adaptive-images/adaptive-images-script.php last;
    try_files $uri $uri/ /index.php?$args;
}

# other locations here
...

location ~* .(js|css|ico)$ {
    expires               60d;
    log_not_found         off;
}