Page 1 of 1

Get Current url of a loaded page with PHP

Posted: Mon Apr 09, 2012 12:10 am
by vhiguita
Hi,

I have a question, I am using document.location http://www.flights24.com/flight/wait/?s ... Airline%5D, it redirects me to this url http://www.flights24.com/flight/encodes ... c0abdeb7d/, I need to get this last url to send like parameter to another page. This is my php code.
----------------------------------------------------------------------------------------
echo "<script>document.location='http://www.flights24.com/flight/wait?sF ... ='</script>";


$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https')
=== FALSE ? 'http' : 'https';
$host = $_SERVER['HTTP_HOST'];
$script = $_SERVER['SCRIPT_NAME'];
$params = $_SERVER['QUERY_STRING'];

$currentUrl = $protocol . '://' . $host . $script . '?' . $params;

echo $currentUrl;
header( 'Location: http://localhost/simplehtmldom_1_5/exam ... l.php?url='. $rez ) ;
-----------------------------------------------------------------------------------------

Thank you very much.

Re: Get Current url of a loaded page with PHP

Posted: Mon Jun 04, 2012 3:20 am
by Live24x7
check this out, this might help

http://knowpapa.com/url/

Re: Get Current url of a loaded page with PHP

Posted: Mon Jun 04, 2012 2:03 pm
by tr0gd0rr
Are you saying you need to get the effective URL of another page on the internet? You could use curl and then use curl_getinfo to get CURLINFO_EFFECTIVE_URL.