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
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.
use $_SERVER['HTTP_REFERER'];
to get last url. I use this only.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.