raotnv Posted February 24, 2009 Share Posted February 24, 2009 Dear All Could any body shed some light on my problem. What I am trying to do is I have one URL1 (http://www.domain1.com) and user click this url1 and which redirects to URL2 (http://www.domain2.com). But my problem here is I know what could be URL1 but never know URL2 which I need to track for some encoded strings in url they append when they loaded. Is there any way I can track the final forwarded URL in php?. or even java script also fine for me if you have some ideas. Appreciate your help in advance. Thanks Rao Link to comment https://forums.phpfreaks.com/topic/146718-how-can-i-track-url-forwarding/ Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 If you do a cUrl request with PHP, you can use this: http://us3.php.net/manual/en/function.curl-getinfo.php to get the Last Effective URL Link to comment https://forums.phpfreaks.com/topic/146718-how-can-i-track-url-forwarding/#findComment-770285 Share on other sites More sharing options...
raotnv Posted February 24, 2009 Author Share Posted February 24, 2009 Thanks for the response. Some how it is still showing same first URL only when I use curl_getInfo. Please check what I am doing here. $ch = curl_init($url); $execute = curl_exec($ch); if(!curl_errno($ch)) { $stringData = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); } Appreciate any further ideas. Rao If you do a cUrl request with PHP, you can use this: http://us3.php.net/manual/en/function.curl-getinfo.php to get the Last Effective URL Link to comment https://forums.phpfreaks.com/topic/146718-how-can-i-track-url-forwarding/#findComment-770576 Share on other sites More sharing options...
rhodesa Posted February 25, 2009 Share Posted February 25, 2009 <?php $ch = curl_init('http://www.gmail.com'); curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_exec($ch); $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); print $url; ?> Link to comment https://forums.phpfreaks.com/topic/146718-how-can-i-track-url-forwarding/#findComment-771432 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.