Re: Getting the URL
| From: | Matt McClanahan | Date: | Mon, 16 Oct 2000 18:47:42 +0000 |
| Subject: | Re: Getting the URL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-20419@lists.php.net to get a copy of this message | ||
On Mon, 16 Oct 2000, Todd Cary wrote:
> At the top of the script, I have the following code. My problem is how
> to get the URL. Is the URL root available in IIS?
How much of the URL do you want?
About the closest you can come to a complete URL 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.
There are a few other related variables. $SERVER_NAME doesn't include the
port if you don't care about it. Additionally, $SCRIPT_NAME removes
any get-mode parameters that may have been sent to a file.
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