ama*_*emi 12 wordpress .htaccess cors
我遇到以下错误来自" http://static.example.com "的字体已被阻止通过跨源资源共享策略加载:请求中没有"Access-Control-Allow-Origin"标头资源.因此,不允许来源" http://www.example.com "访问.
我在下面的.htaccess文件中使用以下COR设置
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
ExpiresByType text/cache-manifest "access plus 0 seconds"
........
<IfModule mod_headers.c>
Header append Cache-Control "public"
<FilesMatch "\.(ttf|otf|eot|woff|svg)$">
SetEnvIf Origin "^http://(.*)?example.com$" origin_is=$0
Header set Access-Control-Allow-Origin %{origin_is}e env=origin_is
</FilesMatch>
<FilesMatch "\.(js|css|xml|gz)$">
Header append Vary: Accept-Encoding
</FilesMatch>
</IfModule>
</IfModule>
Run Code Online (Sandbox Code Playgroud)
我需要帮助
bg1*_*7aw 17
在您的.htaccess文件中尝试此操作:
# Allow font assets to be used across domains and subdomains
<FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)
您可以在我发现的这篇优秀文章中阅读有关此问题的更多信息:https://expressionengine.com/learn/cross-origin-resource-sharing-cors