如何为Apache httpd服务器启用CORS? (逐步处理)

时间:2015-08-28 14:38:22

标签: apache .htaccess cors

我想知道是否有人可以帮助我在我的Apache Web服务器上设置CORS。我将非常感谢一步一步的过程,因为许多在线网站都在告诉我不同​​的事情。就像我需要在httpd.conf或ssl.conf文件上做什么,把我的.htaccess文件放在哪里等等。

任何帮助将不胜感激。谢谢!

2 个答案:

答案 0 :(得分:2)

# edit your conf/httpd.conf file.  Verify that the headers module is loaded
LoadModule headers_module modules/mod_headers.so

# to whitelist every origin, use
Header set Access-Control-Allow-Origin "*"

更多信息:http://enable-cors.org/server_apache.html

答案 1 :(得分:0)

以上答案正确 放入httpd.conf  应该将其更改为您将DocumentRoot设置为的内容。

在Ubuntu上,httpd.conf位于目录/ etc / apache2中。 apache2.conf也位于/ etc / apache2中。

在/ etc / httpd / conf / httpd路径中的CENTOS 6 httpd.conf。

.....   标头集访问控制允许来源“ *”