Get Current url of a loaded page with PHP

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
vhiguita
Forum Newbie
Posts: 4
Joined: Mon Apr 09, 2012 12:06 am

Get Current url of a loaded page with PHP

Post 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.
Live24x7
Forum Contributor
Posts: 194
Joined: Sat Nov 19, 2011 9:32 am

Re: Get Current url of a loaded page with PHP

Post by Live24x7 »

check this out, this might help

http://knowpapa.com/url/
User avatar
tr0gd0rr
Forum Contributor
Posts: 305
Joined: Thu May 11, 2006 8:58 pm
Location: Utah, USA

Re: Get Current url of a loaded page with PHP

Post 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.
Post Reply