首页 > 解决方案 > 字体的 Cors 问题

问题描述

目前在 wordpress 网站上有一些 cors 政策问题。

我尝试编辑 htaccess。如下所示的复制粘贴但事实证明不起作用。我是wordpress的新手,只在这里进行维护。

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

IfModule mod_setenvif.c>
  <IfModule mod_headers.c>
    # mod_headers, y u no match by Content-Type?!
    <FilesMatch "\.(gif|png|jpe?g|svg|svgz|ico|webp)$">
      SetEnvIf Origin ":" IS_CORS
      Header set Access-Control-Allow-Origin "*" env=IS_CORS
    </FilesMatch>
  </IfModule>
</IfModule>

<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>

Header add Access-Control-Allow-Origin "*"



Access to font at 'https://interiorsfurniture.com/assets/themes/bridge-child/fonts/fontawesome-webfont.woff2?v=4.7.0' from origin 'https://www.interiorsfurniture.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

标签: wordpress.htaccessfontscors

解决方案


推荐阅读