markdown Web字体的CORS跨源资源共享问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown Web字体的CORS跨源资源共享问题相关的知识,希望对你有一定的参考价值。

In order to fix an issue for your WordPress blog, just put below into your .htaccess file.

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

**Note:** Access-Control-Allow-Origin "*" allows you to access all resources and webfonts from all domains. For security reasons this should be modified to only the domains that you need access from.

If you need to allow multiple domains:

```
<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$">
    SetEnvIf Origin "http(s)?://(www\.)?(caro-acro.ca)$" AccessControlAllowOrigin=$0
    Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
  </FilesMatch>
</IfModule>
```


Sources:

- http://crunchify.com/how-to-fix-access-control-allow-origin-issue-for-your-https-enabled-wordpress-site-and-maxcdn/
- http://stackoverflow.com/questions/1653308/access-control-allow-origin-multiple-origin-domains

以上是关于markdown Web字体的CORS跨源资源共享问题的主要内容,如果未能解决你的问题,请参考以下文章