Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- CURL and URL redirection question
- John Drako
November 15, 2005, 6:32 am
rate this thread
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://somedomain.com/somepath.html "
HTTP/1.1 303 See Other
Date: Tue, 15 Nov 2005 06:15:59 GMT
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?
- Nicholas Sherlock
November 15, 2005, 7:38 am