我有两个虚拟主机,xyz.com 和 abc.com。从 xyz.com 我正在向http://abc.com/test进行 curl 后调用(使用 PHP) 这将返回“403 错误 - 禁止”(http://abc.com/test 在浏览器中工作正常)
我知道这个问题听起来很重复。对此感到抱歉,因为我已经完成了之前答案中给出的所有解决方案,但没有任何效果:-(
- 我在 Apache 中的根文件夹(doc root)有 775 个权限。
在 httpd.conf 我的控件如下
Options FollowSymLinks AllowOverride All Order allow,deny Allow from all
- 我还尝试在代码中添加 USERAGENT (of firefox) 来模拟浏览器。
我没有得到 Apache 的确切问题。我正在使用 Apache 2.4
有人可以帮忙解决这个问题吗?
更新 以下是我用于发送请求的代码。
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
curl_setopt($curl, CURLOPT_URL, 'http://abc.com/test');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, 'a=b&c=d&e=f');
$headers[] = 'Content-Type:application/x-www-form-urlencoded';
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($curl);