Php Curl重定向:为什么FOLLOWLOCATION不跟随正确的域

Php Curl重定向:为什么FOLLOWLOCATION不跟随正确的域,php,curl,Php,Curl,我正试图抓取一个网站,但我试图抓取的页面包含指向另一个页面的重定向。我将FOLLOWLOCATION参数放在curl上,但我到达了一个url,依此类推 问题是重定向是可行的,但域是不正确的,因为它是我的,而不是刮页。以下是代码: <?php // create a new CURL resource $ch = curl_init(); // set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, "http

我正试图抓取一个网站,但我试图抓取的页面包含指向另一个页面的重定向。我将FOLLOWLOCATION参数放在curl上,但我到达了一个url,依此类推

问题是重定向是可行的,但域是不正确的,因为它是我的,而不是刮页。以下是代码:

<?php
// create a new CURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://voli.govolo.it/etape1.cfm?ref=2008052701&destination=484&Provenance=320&Date_Depart=11/9/2010&Date_Retour=18/9/2010&AllerRetour=1&Adultes=1&ENFANTS=0&BEBES=0&dated=110910&dater=180910&TypeClasse=0&langue=it");
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);    

// grab URL and pass it to the browser
$esito = curl_exec($ch);
print_r(curl_getinfo($ch));
echo $esito;
// close CURL resource, and free up system resources
curl_close($ch);
?>
页面将被重定向为etape1.cfm到etape2.cfm,但我得到404错误,因为我看到了?。。。而不是


为什么FOLLOWLOCATION不遵循正确的域?

问题不在于curl。第一个url发送的部分内容如下:

<script language="JavaScript" type="text/javascript">
<!--

    function historyDeleteAndRedirect()
    {

        window.location.replace('etape2.cfm?ref=2008052701&destination=484&Provenance=320&Date_Depart=11/9/2010&Date_Retour=18/9/2010&AllerRetour=1&Adultes=1&ENFANTS=0&BEBES=0&dated=110910&dater=180910&TypeClasse=0&langue=it');


    //alert(window.location.href);
    //alert(document.referrer);
    }

//-->
</script>

由于您不是以正常方式访问该站点,因此此javascript会中断,因为您实际上是在访问localhost而不是WhateVersionThesis.com。记住,curl在服务器上工作。那么你在打http://localhost/etape1.cfm?...... 由于.replace不是绝对URL,您的浏览器正在执行正确的操作并重新使用localhost。

您包含的URL不会为我重定向。是的,因为我添加了NOBODY参数,等等,我把它删除了我是说URL本身http://voli.govolo.it/etape1.cfm?ref=2008052701&destination=484&Provenance=320&Date_Depart=11/9/2010&Date_Retour=18/9/2010&AllerRetour=1&Adultes=1&ENFANTS=0&BEBES=0&dated=110910&dater=180910&TypeClasse=0&langue=it 在我的浏览器中显示正常,没有重定向或重定向标题。你的代码的输出是什么?