访问控制允许来源头不工作 [英] Access-Control-Allow-Origin headers not working

查看:123
本文介绍了访问控制允许来源头不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管我已经在我的.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>

它仍然无法正常工作!

It still does not work!

当我得到的目录它确实给了我想要的标题,但只要我下载特定文件的标题是无处可寻!

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!

能有多难呢?

推荐答案

尝试

<FilesMatch "\.(gif|jpe?g|png|js|json|xml)$">
  <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
  </IfModule>
</FilesMatch>

这篇关于访问控制允许来源头不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆