You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress网站Web Fonts报404/410错误,已排除插件冲突求解决方法

Hey there, let's work through this web fonts issue you're having with Fetch WordPress—since you've already ruled out plugin conflicts and confirmed the font files exist on your server, we can focus on the most likely culprits here:

1. Verify the font file's direct accessibility & permissions
  • First, paste the full URL of one of your font files (like https://yourdomain.com/wp-content/themes/your-theme/fonts/your-font.woff2) directly into your browser's address bar. If it fails to download or throws a 403/404 error, the problem is likely file permissions:
    • Set individual font files to 644 and their parent folders to 755 via FTP or your server control panel (e.g., cPanel). This ensures the server allows public access to the files.
  • If the file loads fine directly but GTmetrix still flags an error, move on to checking Fetch WordPress's optimization rules.
2. Check Fetch WordPress's font optimization settings

Fetch has built-in resource optimization tools that might be rewriting font paths incorrectly:

  • Navigate to Fetch's settings panel and look for sections like "Resource Optimization" or "Font Optimization". Temporarily disable features like font preloading or font hosting/optimization, then re-run GTmetrix.
  • If the error disappears after disabling these features, add your font file paths to Fetch's exclusion list or optimization whitelist to prevent it from altering those files' loading logic.
3. Audit your @font-face code implementation

Incorrect path references in your theme's CSS or functions.php can cause loading issues, even if the files exist:

  • Open your theme's custom CSS or style.css file and check the @font-face rules. Replace relative paths with absolute, full-domain paths to avoid path resolution errors. For example:
    Bad (relative path that might be rewritten by Fetch):
    @font-face {
      font-family: 'CustomFont';
      src: url('../fonts/custom-font.woff2');
    }
    
    Good (absolute path that won't be misinterpreted):
    @font-face {
      font-family: 'CustomFont';
      src: url('https://yourdomain.com/wp-content/themes/your-theme/fonts/custom-font.woff2');
    }
    
  • If you're enqueuing fonts via functions.php, double-check that the wp_enqueue_style or wp_enqueue_script calls use the correct file URLs.
4. Fix server MIME type configurations

Servers often throw font errors if they don't recognize font file types. Here's how to fix it:

  • For Apache servers, add these lines to your root .htaccess file:
    AddType font/woff .woff
    AddType font/woff2 .woff2
    AddType font/ttf .ttf
    AddType font/eot .eot
    AddType font/otf .otf
    
  • For Nginx servers, add these lines to your server block configuration:
    types {
      font/woff woff;
      font/woff2 woff2;
      font/ttf ttf;
      font/eot eot;
      font/otf otf;
    }
    
  • Restart your server after making changes, then re-test with GTmetrix.
5. Clear all layers of cache

Fetch WordPress, server-level caches (like Varnish), and CDNs (like Cloudflare) might be storing outdated font loading data:

  • Clear Fetch's internal cache via its settings panel.
  • Flush your browser cache or use incognito mode to test.
  • If you use a CDN or server cache, clear those as well to ensure your latest font configurations are served.

内容的提问来源于stack exchange,提问作者FormaL

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:51:21