How to retrieve complete URL from address bar using PHP?
php
Solution
How about this?
function getAddress() {
$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
echo getAddress();
Problem
Possible Duplicate: How to get full URL on the address bar using PHP I use this function, but it does not work all the time. Can anyone give a hint? ``` function sofa_get_uri() { $host = $_SERVER['SERVER_NAME']; $self = $_SERVER["REQUEST_URI"]; $query = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null; $ref = !empty($query) ? "http://$host$self?$query" : "http://$host$self"; return $ref; } ``` I want to retrieve the link in address bar (exactly) to use it to refer user back when he sign out. The urls are different: ``` http://domain.com/sample/address/?arg=bla http://domain.com/?show=bla&act=bla&view=bla http://domain.com/nice/permalinks/setup ``` But I can't get a function that works on all cases and give me the true referrer. Hint please.