PHP cURL 获取 Location: 重定向的最终 URL

PHP 代码:

$url = 'https://www.baidu.com/link?url=6Ajd8F6TZ-n2p7SVuGxhKyLN5-RKI6FITj6RHWyH1l3';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_NOBODY, 1); //不返回 BODY 页面内容
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //不直接输出
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //返回最后的 Location
curl_exec($ch);
$info = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
curl_close($ch);
echo $info;

 

以上 URL 最终重定向到 https://hexingxing.cn/