Log in

View Full Version : Current page's exact URL?


filburt1
11-04-2002, 10:21 PM
How can I get the full and exact URL of the current page? i.e., protocol://server:port/path/filename?argument1=value1&argument2=value2...

I know how to construct it but I thought that there might be a superglobal that already contains this.

Dean C
11-05-2002, 05:06 PM
in a phpinfo file?

- miSt

filburt1
11-05-2002, 05:46 PM
...?

Using PHP, if I used phpinfo I'd already know the page's URL :p

Logician
11-05-2002, 09:59 PM
first get root dir with $_SERVER['DOCUMENT_ROOT'] or $DOCUMENT_ROOT, then you can convert it yourself to exact URL. pathinfo() function will help you while you are doing so..

Scott MacVicar
11-05-2002, 10:16 PM
$_SERVER['HTTP_HOST']
$_SERVER['SERVER_PORT']
$_SERVER['REQUEST_URI']

not sure about the protocol an if statement?

if ($_SERVER['SERVER_PORT'] == 443) {
$p = 'https://';
} else {
$p = 'http://';
}