出于某种原因,当我在服务器上对测试URL进行CURL调用时,请求会被强行启动到带有“www”的URL。 VirtualHost没有任何设置来修改URL,htaccess似乎也没有。在浏览器中直接请求“http://sub.domain.com/test.html”时,我会获得实际的页面内容。
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://sub.domain.com/test.html');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close ($ch);
return varDumpToString($info);
返回:
array(22) {
["url"]=>
string(37) "http://sub.domain.com/test.html"
["content_type"]=>
string(29) "text/html; charset=iso-8859-1"
["http_code"]=>
int(301)
["header_size"]=>
int(311)
["request_size"]=>
int(68)
["filetime"]=>
int(-1)
["ssl_verify_result"]=>
int(0)
["redirect_count"]=>
int(0)
["total_time"]=>
float(0.003001)
["namelookup_time"]=>
float(0.000552)
["connect_time"]=>
float(0.002219)
["pretransfer_time"]=>
float(0.002226)
["size_upload"]=>
float(0)
["size_download"]=>
float(331)
["speed_download"]=>
float(110296)
["speed_upload"]=>
float(0)
["download_content_length"]=>
float(331)
["upload_content_length"]=>
float(0)
["starttransfer_time"]=>
float(0.002958)
["redirect_time"]=>
float(0)
["certinfo"]=>
array(0) {
}
["redirect_url"]=>
string(41) "http://www.sub.domain.com/test.html"
}
有任何帮助吗?感谢。