1.修改服务器配置文件
<Directory /www/web/yuming.com/public_html/>
Options FollowSymLinks
AllowOverride All
Require all granted
Header set Access-Control-Allow-Origin *
</Directory>
2.编辑httpd.conf
找下面这行,把#去掉,目的是开启apache头信息自定义模块
#LoadModule headers_module modules/mod_headers.so
重点内容
Access-Control-Allow-Origin *
意思是对这个域名的资源进行访问时,添加一个头信息
最后重启服务器生效
配置Apache跨域访问
本文介绍如何通过修改Apache服务器配置实现跨域资源共享(CORS),包括编辑服务器配置文件和httpd.conf文件,添加Access-Control-Allow-Origin头信息,并重启服务器使设置生效。
774

被折叠的 条评论
为什么被折叠?



