我需要在 ubuntu 上配置 apache 来接受 POST 跨域。
我试过这样http://enable-cors.org/server_apache.html:
- 安装 mod_header
- 添加 header('Access-Control-Allow-Origin: '.$_SERVER['HTTP_ORIGIN']); header('Access-Control-Allow-Methods: POST, GET, OPTIONS'); header('Access-Control-Max-Age: 1000'); header('Access-Control-Allow-Headers: Content-Type');
但这不起作用。
请求标头:
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:accept, cache-control, origin, x-requested-with, x-file-name, content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:xxx.amazonaws.com
Origin:local.com
Referer:local.com/test/test.php
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31
响应标头:
Access-Control-Allow-Methods:POST, GET, OPTIONS
Access-Control-Allow-Origin:*
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:27
Content-Type:text/html Date:Fri, 10 May 2013 10:30:10 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.2.22 (Ubuntu) Vary:Accept-Encoding X-Powered-By:PHP/5.3.10-1ubuntu3.6
任何人都可以帮助我吗?太感谢了