Jump to content

How can I track URL forwarding


raotnv

Recommended Posts

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

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

<?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;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.