【发布时间】:2017-10-12 19:51:57
【问题描述】:
我正在使用Apache24 在Windows Server 2016 上部署我的网站以提供静态文件。它们都可以(js、css、图像),但字体文件。
通过互联网阅读后,我将其添加到httpd.conf 文件中:
<IfModule headers_module>
<FilesMatch "\.(ttf|otf|eot|woff|woff2|font.css|css|js)$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
</IfModule>
并取消注释行:
LoadModule headers_module modules/mod_headers.so
但我仍然收到此错误,其中 server_ip 是真实的服务器 IP 地址
CORS 策略已阻止从源“http://server_ip:8080”访问位于“http://server_ip/static/control/fonts/glyphicons-halflings-regular.woff2”的字体:请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许访问 Origin 'http://server_ip:8080'。
这是与使用ip地址而不是域有关的问题吗?我仍在等待域,所以我必须指向 ip。
我在 apache 配置中遗漏了什么吗?因为我也加了
<IfModule mime_module>
AddType application/x-font-ttf .ttc .ttf
AddType application/opentype .otf
...
</IfModule>
...
<IfModule rewrite_module>
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>
没有结果。
任何帮助将不胜感激。 谢谢。
【问题讨论】:
-
感谢您在没有 cmets 的情况下投票...
标签: apache fonts cors httpd.conf