Search code examples
urlhtml-parsingenvironment-variablesssi

Looking for SSI Environment Variable(s) for Document URL


I'm looking for an SSI Environment Variable that can return the Document URL...

http://www.mySite.com/path/myPage.html

Right now, I'm cobbling it together using these other environment variables...

<!--#echo var="SERVER_NAME" -->

gives this: http://www.mySite.com, and...

<!--#echo var="DOCUMENT_URI" -->

gives this: /path/myPage.html.

So I'm putting them both together, like this...

http://<!--#echo var="SERVER_NAME" --><!--#echo var="DOCUMENT_URI" -->

And it works just fine.

Two questions:

1) Is there a single SSI Environment Variable for the full Document URL? I've been searching for a while but cannot seem to find.

2) If not, can somebody explain why? There is one called HTTP_REFERER that returns the full URL of the referer, so why not one that returns the full URL of the current location, something like a DOCUMENT_URL?


Solution

  • 1) No, there isn't. You can check this by a simple dump of all environment values:

    <pre>
    <!--#printenv -->
    </pre>
    

    2) Why? I'm not sure, perhaps because it would be redundant to have that in a single variable where you can cobble it together as you did. That and the fact that you might want to also do certain things like ignore the server protocol (HTTP or HTTPS) or use a different port, or any number of other reasons.

    Hope that helps