0

I'm using the function get_permalink() to try and get the Current URL.

I've noticed it doesn't actually get the exact URL as shown in the address bar, for example if it is formatted like:

domain.com?s=one&two&three=0&four=

Is there a function to get the exact current URL?

Sam
  • 37
  • 1
  • 9
  • 3
    Possible duplicate of [Get the full URL in PHP](http://stackoverflow.com/questions/6768793/get-the-full-url-in-php) – Daerik Dec 08 '16 at 21:44

1 Answers1

0
<?php
function curPageURL() {
 $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on")     {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".    $_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  $pageURL .= $_SERVER["SERVER_NAME"].    $_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}
?>
KAGG Design
  • 1,945
  • 8
  • 14