卷曲请求不起作用

时间:2016-09-23 06:37:02

标签: php curl http-status-code-302

您好我有一个网站说abc.com并且在子文件夹abc.com/site中安装了另一个网站。当我从abc.com/site向abc.com发送卷曲请求时它显示302。 下面是我的代码

$ch = curl_init();
$data['username'] = 'abc';
$data['password'] = 'abc';
curl_setopt($ch, CURLOPT_URL, "abc.com/site ");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$a = curl_exec($ch);
print_r($a); 

但是当我从开发站点向生产站点发出相同的请求时,它运行良好。似乎它不是在同一个起源上工作。请建议我如何解决这个问题

1 个答案:

答案 0 :(得分:0)

302是重定向,您已明确告知curl不遵循将CURLOPT_FOLLOWLOCATION设置为false的重定向...