我正在设置htaccess
。我知道它设置正确,因为如果我设置另一个标题:
Header set Access-Control-Allow-Origin2: *
然后chrome确实看到了这一点。然而,一旦我移除2,铬就完全忽略了它。如果我将我的文件设为PHP文件并将其放入其中:
<?php header("Access-Control-Allow-Origin: *"); ?>
然后它有效。
以下是Chrome浏览器报告的 .htaccess 方法的响应标题,我需要这样做,而不是:
HTTP/1.1 304 Not Modified
Date: Sun, 30 Mar 2014 00:13:06 GMT
Server: Apache/2.2.22 (Ubuntu)
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
ETag: "208f3-178a2-4f5c4f119cd34"
Vary: Accept-Encoding
以下是Chrome从PHP方法报告的响应标头,由于某种原因,它可以正常工作:
HTTP/1.1 200 OK
Date: Sun, 30 Mar 2014 00:13:09 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.10
Access-Control-Allow-Origin: *
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 23
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Content-Type: text/html
同样,我知道htaccess
正在设置标题,即使我转到检查响应标头的在线服务,我也会看到:
HTTP/1.1 200 OK
Date: Sun, 30 Mar 2014 00:18:14 GMT
Server: Apache/2.2.22 (Ubuntu)
Last-Modified: Sat, 29 Mar 2014 20:48:34 GMT
ETag: "208f3-178a2-4f5c4f119cd34"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Access-Control-Allow-Origin: *
Content-Length: 33393
Content-Type: application/javascript