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

问题描述 投票:0回答:1

我正在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专家给我正确的重写配置并解决它!

提前感谢

wordpress nginx nginx-location nginx-config
1个回答
0
投票

您的错误是您的所有图像请求均由带有此location块的Nginx处理:

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;
}
© www.soinside.com 2019 - 2024. All rights reserved.