I want to know whow to find the reditected url. like when someone uses a php header to redirect how can I use php to find the destination url?
If it redirects - destination url means the site where you are being redirected .. Am I wrong ? In that case - why you want to get it if you can see it in address bar ? ** You can't get it via php ..
This should work, but only if the redirection is from HTTP header. <?php $url = 'http://test.com/test.php';// the url to check $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_REFERER, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_HEADER, true);// must be true $result = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); if ($info['http_code'] == 301 || $info['http_code'] == 302) { list($headers, $body) = explode("\r\n\r\n", $result); preg_match('/location:([ ]+)?(.*)?/i', $headers, $match); $redirectedTo = trim($match[2]);// yes, put a trim() here echo 'You are redirected to <strong>'.$redirectedTo.'</strong>'; } else { echo 'Not redirected'; } ?> PHP:
You're going to have to show an example or explain a little better. Are you trying to get data on incoming connections to your site or outgoing proxy type connections?