Re: Get current URL

From: Date: Mon, 09 Oct 2000 07:00:22 +0000
Subject: Re: Get current URL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19149@lists.php.net to get a copy of this message
On Mon, 9 Oct 2000, Scott Poarch wrote: > There must be an easy answer to this, but I can't find it: > > How do you set the complete URL of the current page to a variable? I know > about PHP_SELF, but that only gives me part of the URL. > > Any help would be greatly appreciated. About the closest you can come is $HTTP_HOST . $REQUEST_URI That'll give you www.example.com/path/to/file.php?arg=val for example, but the http:// or https:// isn't there. To see that, you'd need to check what $SERVER_PROTOCOL was (HTTP/1.0, for example), unless it's safe in your situation to just assume it'll be http. $SERVER_NAME doesn't include the port, so it isn't as reliable as $HTTP_HOST. Additionally, $SCRIPT_NAME doesn't include any get parameters that may have been sent. For a complete listing of all the variables available in your environment, load a page containing <?php phpinfo() ?> and look over the 'Apache Environment' section. Matt

« previous php.general (#19149) next »