Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the visible URL

Tags:

php

I'm wondering how i can get URL (the visible one in the bar). I have tried to google it, and lots of answers is to write this:

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

But it will get the path of the file you are in. I would like to just get the visible url, like this:

www.something.com/index.php?page=teams

And then only get the url that you can see, and not the included url. When i do this, ill get something like:

 www.something.com/search.php

because im printing the URL inside the included file search.php.

I hope you understand my question, even though it's kinda bad written, i find it very hard to explain my problem.

like image 829
Emil Møller Ringgaard Avatar asked Feb 25 '26 11:02

Emil Møller Ringgaard


1 Answers

for url : $_SERVER['REQUEST_URI']

after ? in url : $_SERVER['QUERY_STRING']

like image 80
Steve Bals Avatar answered Feb 28 '26 01:02

Steve Bals