【发布时间】:2012-03-28 17:55:51
【问题描述】:
您好,我有以下问题,
我想用 php 建立一个网站。我使用了 CURL,但在我的服务器上我设置了 open_basedir。
所以,我收到以下错误消息:
CURLOPT_FOLLOWLOCATION 在安全模式下或设置了 open_basedir 时无法激活
代码是:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$store = curl_exec ($ch);
$error = curl_error ($ch);
return $store;
有没有其他方法可以使用 php 加载网站?!
谢谢
【问题讨论】:
-
您可能根本不需要
CURLOPT_FOLLOWLOCATION。只需删除该行。 -
你仍然可以使用 curl,你只需要手动进行重定向。
-
@Brian:仅当特定 url 重定向到实际内容时。不是每个人都使用重定向...