Reputation: 65
I had used this code to get redirected url in $last_url string :
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "www.djgol.com/files/download/id/163799");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
$last_url= curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
$output = curl_exec($ch);
echo $last_url;
curl_close($ch);
?>
but i am unable to get redirected url ,, please help me
Upvotes: 0
Views: 1487
Reputation:
You're trying to get the URL before starting the request. Try moving the $last_url= curl_getinfo($ch,CURLINFO_EFFECTIVE_URL);
line to after the curl_exec($ch);
call.
Upvotes: 1