执行请求时,PHP 的 curl 似乎不包含 Host 标头:
<?php
$handle = curl_init('http://example.com/');
curl_setopt_array($handle, array(
CURLOPT_USERAGENT => 'test ua',
CURLOPT_REFERER => 'http://example.org/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_PROXY => '127.0.0.1:8080',
CURLOPT_PROXYTYPE => CURLPROXY_HTTP,
//Doesn't work if you specify it manually or leave it out:
CURLOPT_HTTPHEADER => array(
'Host: example.com'
)
));
print_r(curl_getinfo($handle));
echo curl_exec($handle);
?>