CURL and URL redirection question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a database with a lot of links. Every so often I run a script to  
verify if the URLs are still valid. I weed out the ones with the 404  

However, many responses are of the 303 kind (URL redirection).

with the following options, CURL does not return the redirection URL.

$ch = curl_init();  
$ret = curl_setopt ($ch, CURLOPT_URL,  
" ");  
$ret = curl_setopt ($ch, CURLOPT_HEADER, 1);  
$ret = curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);  
$ret = curl_setopt ($ch, CURLOPT_NOBODY, 1);  
$ret = curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
$ret = curl_exec($ch);
$info = curl_getinfo($ch);

I would like to retrieve the URL that the URL redirects to so that the  
script can update the URL directly.

on the command line the following command yields the following result:

% curl -I " "
HTTP/1.1 303 See Other
Date: Tue, 15 Nov 2005 06:15:59 GMT
Server: Apache
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1
X-Pad: avoid browser bug

is it possible to retrieve the 'Location' field via CURL in PHP?

Re: CURL and URL redirection question

John Drako wrote:
Quoted text here. Click to load it

Use FollowLocation.

Nicholas Sherlock

Re: CURL and URL redirection question

On Tue, 15 Nov 2005 02:38:09 -0500, Nicholas Sherlock wrote

Quoted text here. Click to load it

Thanks, that worked :)

CURL has so many options that it's a bit confusing to read all of them.

Site Timeline