cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

CURLOPT_FOLLOWLOCATION not redirecting

From: John Miedema <mail_at_johnmiedema.ca>
Date: Mon, 02 Feb 2009 10:41:29 -0500

Hi, CURLOPT_FOLLOWLOCATION not redirecting. I'm fairly new to CURL but I
think everything is setup and configured correctly:

FILE: test1.htm - uses a meta REFRESH to redirect to test2.htm. Body
contains some text: 'abc'. Redirects properly if opened in a browser.

FILE: test2.htm - the body contains some text, 'def'.

FILE: test.php - has the following php code to follow redirects

   $ch = curl_init('http://localhost/test1.htm');
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
   $output = curl_exec($ch);
   echo stripos($output, 'abc'); //finds the text from test1.htm
   echo stripos($output, 'def'); //does not find the text from test2.htm
   curl_close($ch);

PROBLEM: I can find the text 'abc' from the body of test1.htm, but not
'def' from test2.htm. curl_getinfo($ch,CURLINFO_EFFECTIVE_URL) shows the
url has not changed. I.e., No redirect is occurring.

safe_mode: Off
open_basedir: no value
cURL Information libcurl/7.19.2 OpenSSL/0.9.8i zlib/1.2.3
Also tried this on my production server, same problem

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-02-02