title: How to retrieve complete URL from address bar using PHP?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4768181/how-to-get-full-url-on-the-address-bar-using-php">How to get full URL on the address bar using PHP</a>  </p>
  </blockquote>
  
  
  
  <p>I use this function, but it does not work all the time. Can anyone give a hint?</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>http://domain.com/sample/address/?arg=bla
  
  http://domain.com/?show=bla&amp;act=bla&amp;view=bla
  
  http://domain.com/nice/permalinks/setup
  </code></pre>
  
  <p>But I can't get a function that works on all cases and give me the true referrer.</p>
  
  <p>Hint please.</p>