You are here: CURL and URL redirection question « All PHP « IT news, forums, messages
CURL and URL redirection question

Posted by John Drako on 11/15/05 08:32

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
response.

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,
"http://somedomain.com/somepath.html");
$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);
curl_close($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
Server: Apache
Location: http://somedomain.com/newpath.html
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?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация