PHP中的cURL并不总是遵循重定向

I have this code:

for($i = $start; $i <= $end ; $i++)
    {
        $url = "http://xxx.co.il/yyy?zzz=$i";
        $ch = curl_init();
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; he-IL; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
        curl_setopt ($ch, CURLOPT_REFERER, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        $result = curl_exec($ch);
        $info = curl_getinfo($ch);
        curl_close($ch);

        if($info['url'] == "http://www.xxx.co.il/abc")
        {
                echo "<br />%^$i^%<br />";   
        }
        else
        {
                echo "$info['url']";
        }

The url I'm trying to cURL always redirects to another page. But, sometimes $info['url'] stills is the original url. Why is that? When I try the $i that got stuck manually it does redirect me.

The code used to work, and I haven't changed anything that I'm aware of. Most of the time it works. Either with case 1 (The 'if') or with case 2 (The 'else'). Any ideas why this is happening? I couldn't find any answer online. Maybe it's because I didn't really know how to put the problem into keywords.

When I run this on my server it works, but my computer has a 100mbps internet connection which makes it a lot faster. Plus, I'd rather overload my computer than the server.

Thanks!

UPDATE: The problem seem to have stopped. Everything runs smoothly know. I would still like ot hear theories about why this could happen.

Thanks!

A common loop-redirect pitfall is that your client need to manage cookies:

Try to add the following options:

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");