-3

I have a function which looks like this:

function fullURL(){
    $domain = $_SERVER['SERVER_NAME'];
    $path = $_SERVER['PHP_SELF'];
    $raw_url = $domain.$path;
    $url = substr($raw_url, 0, -4);
    echo $url;
}

This generates an URL which looks like 127.0.0.1/aura/profile
But, what if I would use this on a page which uses a $_GET-tag?

Then, my URL won't pick it up.
For example I have news?id=1, when using the function above it just becomes 127.0.0.1/aura/news.
What do I need to add to the function to make it output 127.0.0.1/aura/news?id=(id)?

ann
  • 576
  • 1
  • 10
  • 19

1 Answers1

2

What about this?

$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

Note that you could also do:

$actual_link = "http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];

Original answer: https://stackoverflow.com/a/6768831/3150271

Community
  • 1
  • 1
Emanuel Vintilă
  • 1,911
  • 4
  • 25
  • 35