[英]The 'Access-Control-Allow-Origin' header with apache
[英]Add the Origin from the requests to the Access-Control-Allow-Origin header in the response
我想允许所有来源从我的 apache 服务器获取资源。
而不是添加:
Access-Control-Allow-Origin: *
我希望我的服务器制作一个特殊的响应:
Access-Control-Allow-Origin: <the value of the Origin received in the request>
有什么我可以添加到 httpd.conf 来实现的吗?
似乎可以通过添加这两行来实现:
SetEnvIf Origin ".*\S.*" ORIGIN=$0
Header always set Access-Control-Allow-Origin %{ORIGIN}e env=ORIGIN
正则表达式几乎意味着除换行符、制表符和空格之外的任何内容,因此只要 Origin 不为空,请将其添加到响应标头中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.