wordpress - 需要 Nginx 专家(Wordpress 插件问题)
问题描述
我在 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;
}
推荐阅读
- multithreading - Docker 容器而不是多处理
- r - 如何使用 RevoScaleR 在 SQL Server 中创建表?
- swift - 无法将“AProtocol”.Protocol 类型的值转换为预期的参数类型协议
- javascript - 如何计算 window.prompt 中的单词并按出现次数对其进行排序?
- wordpress - Wordpress自定义字段在指定日期后删除帖子?
- android - 如何使用 window.setSoftInputMode() 组合状态和调整
- ajax - Django 文件上传 Ajax
- javascript - 如何使用 Webpack 独立捆绑 JS 和 CSS 文件?
- c# - DependencyInjection:在调用之前初始化类(必需)?
- flutter - 检测 Flutter 上的推送路由