解决 W3 Total Cache 插件启用页面压缩后 CSS/JS 文件返回 404 错误

https://wuminboke.site/ 2026-10-28 02:40:42 累计浏览 86 次

问题

当 W3 Total Cache 插件内的页面压缩启用后,且正在使用 NGINX 引擎时,/wp-content/cache/minify/ 路径的 CSS/JS 文件返回 404,页面样式丢失

原因:插件在网站跟目录生成的 nginx.conf 伪静态配置文件没有正确加载,导致 URL 重写没有起作用,返回 404 错误


解决方法

方法一

在 W3 Total Cache>常规设置>压缩 内把Rewrite URL structure选项关闭

方法二

在 NGINX 配置文件(或某塔面版内站点设置>配置文件)完结前加入这一行,把/www/wwwroot/example.com替换成网站根目录:

include /www/wwwroot/example.com/nginx.conf;

然后重启 NGINX,以及清除 CDN 的缓存,页面恢复正常


参考:https://wordpress.stackexchange.com/questions/209059/ubuntu-nginx-everything-works-except-rewrite-url-structure



同分类推荐文章

  1. NGINX Gateway Fabric 2.8: IP allow and deny lists, passive health checks, and cookie-based session persistence (2026-11-14 01:10:02)
  2. NGINX Ingress Controller 5.7: HTTP/2 to your upstreams, Opaque Secrets, and cert-manager challenges behind HTTPS redirects (2026-11-14 00:10:02)
  3. Hexo 文章一键发布到微信公众号 (2026-11-13 19:10:02)

查看更多 DevOps 文章 →

建议继续学习

  1. 配置Nginx+uwsgi更方便地部署python应用 (累计阅读 109,257)
  2. 搜狐闪电邮箱的 Nginx/Postfix 使用模式 (累计阅读 34,259)
  3. WordPress插件开发 -- 在插件使用数据库存储数据 (累计阅读 29,568)
  4. 记录一个软中断问题 (累计阅读 17,392)
  5. 解析nginx负载均衡 (累计阅读 17,001)
  6. Nginx模块开发入门 (累计阅读 11,531)
  7. server日志的路径分析 (累计阅读 11,501)
  8. Cacti 添加 Nginx 监控 (累计阅读 11,297)
  9. 检查nginx配置,重载配置以及重启的方法 (累计阅读 11,291)
  10. fsockopen 异步处理 (累计阅读 10,806)