Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.php Subject: Re: cURL and response code 302 Date: Thu, 11 Jul 2013 00:12:13 +0200 Lines: 58 Message-ID: <51DDDC3D.9010609@arnowelzel.de> References: <51DC1D1D.3090905@arnowelzel.de> <51DC2A36.7090005@arnowelzel.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net mXlKmnFknqnGWvMlOSQNMgKNdNPNmW+sy9hesfZLo0bZYqKR7O Cancel-Lock: sha1:bFS2r5bvFmZ5EB48MaIdNF50E5U= User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: Xref: csiph.com comp.lang.php:10063 bill, 2013-07-10 17:09: [...] > using: > > function curl_getNoFollow($url, array $get = NULL, array $options > = array() ){ [...] > I get: > url: http://www.mydomain.com/login/login.cfm, http: 302 > > note the lack of information about the refer to address, which I > need so I can follow. A quick & dirty example without any error handling etc. - just to get the idea: 'http://mydomain.example/foobar', CURLOPT_HEADER => true, CURLOPT_FOLLOWLOCATION => false, CURLOPT_RETURNTRANSFER => true ); $ch = curl_init(); curl_setopt_array($ch, $options); $result = curl_exec($ch); $resultcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); if($resultcode == 302) $redirect = curl_getinfo($ch, CURLINFO_REDIRECT_URL); else $redirect = ''; echo 'Effective URL: '.$url.'
'; echo 'HTTP result code: '.$resultcode.'
'; echo 'Redirection: '.$redirect.'
'; curl_close($ch); ?> See in action at CURLINFO_REDIRECT_URL is not in the documentation but it was added in PHP 5.3.7. Also see . If this does not work for you (e.g. because you have an older PHP version), you have to extract the location header "manually". HTH -- Arno Welzel http://arnowelzel.de http://de-rec-fahrrad.de