Access-Control-Allow-Origin 标头不起作用 [英] Access-Control-Allow-Origin headers not working
本文介绍了Access-Control-Allow-Origin 标头不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
即使我已将其添加到我的 .htaccess 文件中:
Even though I've added this in my .htaccess file:
Header add Access-Control-Allow-Origin "*"
这在我的 apache 配置中:(在一个部分和外部)
And this in my apache config: (Inside a section AND outside)
<Files ~ "\.(gif|jpe?g|png|js|json|xml)$">
Header set Access-Control-Allow-Origin "*"
</Files>
还是不行!
当我得到 DIRECTORY 时,它确实给了我想要的标题,但是一旦我下载了一个特定的文件,就找不到标题了!
When I get the DIRECTORY it does give me the wanted header, but as soon as I download a specific file the header is nowhere to be found!
到底有多难?
推荐答案
try
<FilesMatch "\.(gif|jpe?g|png|js|json|xml)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
这篇关于Access-Control-Allow-Origin 标头不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文