我在nginx上运行一个wordpress网站,除了我的一个插件= 用于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专家给我正确的重写配置并解决它!
提前感谢
发布于 2019-11-13 19:10:35
您的错误是,所有的图像请求都是由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;
}https://stackoverflow.com/questions/58841121
复制相似问题