Full url without variables


/ Published in: PHP
Save to your folder(s)

Based on http://snipplr.com/view/2734/get-full-url/


Copy this code and paste it in your HTML
  1. <?
  2. function full_url()
  3. {
  4. $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
  5. $protocol = substr(strtolower($_SERVER["SERVER_PROTOCOL"]), 0, strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "/")) . $s;
  6. $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
  7. $address = $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
  8. $parseUrl = parse_url(trim($address));
  9. return $parseUrl['scheme'].'://'.$parseUrl['host'].$parseUrl['port'].$parseUrl['path'];
  10. }
  11. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.