今天在调试QQ互联功能时,遇到跨域访问的问题。为了解决301重定向,遇到了不少的坑。
其中有段百度curl的代码,用于处理百度是如何实现从 baidu.com 跳转到 www.baidu.com 效果的。
➜ ~ curl -i http://baidu.com
HTTP/1.1 200 OK
Date: Mon, 15 Dec 2014 14:06:01 GMT
Server: Apache
Cache-Control: max-age=86400
Expires: Tue, 16 Dec 2014 14:06:01 GMT
Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT
ETag: "51-4b4c7d90"
Accept-Ranges: bytes
Content-Length: 81
Connection: Keep-Alive
Content-Type: text/html
<html>
<meta http-equiv="refresh" content="0;url=http://www.baidu.com/">
</html>
我复制了其中的meta部分,网址替换成自己网站的域名:
<meta http-equiv="refresh" content="0;url=http://www.goldarts.cn/">
结果上线调试,发现网页会不停的刷新。