Environment Variables with SSI.
author: jim.cerny@unh.edu
last modified on August 17, 1999
This illustrates a complete list of environment variables.
Background.
Environment variables are used to exchange information
between a Web server and browser. There is a standardized
list of these developed for CGI (Common Gateway Interface)
scripting. SSI supports those plus a few additional ones.
Some of the CGI environment variables provide information
about the server, but most provide information about the
browser. Ways that this information is commonly used
include the activity logging done by Web servers (captures
browser IP address, browser id string, etc.) and by
Web authors who use JavaScript to make decisions (type
of browser, plug-ins available, or to read-write cookies).
Environment Variables.
You can get a block of reported
environment variables with the
directive.
<!--#printenv -->
While informative, this would probably just be
confusing if used on a consumer-oriented Web page:
SCRIPT_URL=/NIS/Courses/SSI/environ-vars.html
SCRIPT_URI=http://unhinfo.unh.edu/NIS/Courses/SSI/environ-vars.html
HTTP_HOST=unhinfo.unh.edu
HTTP_USER_AGENT=CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
HTTP_ACCEPT=Accept: application/xhtml+xml,text/html;q=0.9,text/plain;
HTTP_ACCEPT_LANGUAGE=en-us,en;q=0.5
HTTP_ACCEPT_ENCODING=gzip
HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7
HTTP_CONNECTION=close
HTTP_CACHE_CONTROL=no-cache
HTTP_PRAGMA=no-cache
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
SERVER_SIGNATURE=<address>Apache/2.0.52 (Red Hat) Server at unhinfo.unh.edu Port 80</address>
SERVER_SOFTWARE=Apache/2.0.52 (Red Hat)
SERVER_NAME=unhinfo.unh.edu
SERVER_ADDR=132.177.132.98
SERVER_PORT=80
REMOTE_ADDR=38.103.63.61
DOCUMENT_ROOT=/usr/local/web/data
SERVER_ADMIN=cwis.admin@unh.edu
SCRIPT_FILENAME=/usr/local/web/data/NIS/Courses/SSI/environ-vars.html
REMOTE_PORT=52939
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1
REQUEST_METHOD=GET
QUERY_STRING=
REQUEST_URI=/NIS/Courses/SSI/environ-vars.html
SCRIPT_NAME=/NIS/Courses/SSI/environ-vars.html
DATE_LOCAL=August 28, 2008
DATE_GMT=August 28, 2008
LAST_MODIFIED=August 17, 1999
DOCUMENT_URI=/NIS/Courses/SSI/environ-vars.html
USER_NAME=unhinfo
DOCUMENT_NAME=environ-vars.html
Instead you would probably use one or a few
environment variables selectively, integrated in
your overall page design.
One way is just for
annotation to automatically include date, URL,
or other information on your pages, probably in
the headers or footers.
Another way is in some simple kinds of
flow control (see source in
flow-auth.txt) to customize the material
presented.
This alphabetic list of SSI environment variables is
assembled from an
NCSA CGI list, plus the Apache extensions as
documented and inferred from the
"printenv" directive (see above). When reading any
discussions of SSI, remember that while many servers
support many variables, the specific list is
dependent on the server and its release version.
Remember, too, that these variables were developed
for a programming environment and we've disabled
the SSI
"exec" directive for calling scripts.
Detailed discussion of
that kind of environment is available in books
such as
CGI Programming
by Shishir Gundavaram.
-
AUTH_TYPE
If the server supports user authentication, and the
script is protected, this is the protocol-specific
authetnication method used to validate the user.
(none)
-
CONTENT_LENGTH
Length of the content as given by the client.
(none)
-
CONTENT_TYPE
For queries which have attached information (e.g., POST and PUT),
this is the content type of the data.
(none)
-
DATE_GMT
The current date in Greenwich Mean Time.
August 28, 2008
-
DATE_LOCAL
The current date in the local time zone.
August 28, 2008
-
DOCUMENT_NAME
The filename (excl. directories) of requested document.
environ-vars.html
-
DOCUMENT_ROOT
Directory on the server in which Web documents
are located or "rooted".
/usr/local/web/data
-
DOCUMENT_URI
The URL path of the requested document.
Affected by nesting of SSIs.
/NIS/Courses/SSI/environ-vars.html
-
GATEWAY_INTERFACE
Revision of the CGI specification to which the server complies.
CGI/1.1
-
HTTP_ACCEPT
The MIME types which the client will accept.
Accept: application/xhtml+xml,text/html;q=0.9,text/plain;
-
HTTP_ACCEPT_ENCODING
gzip
-
HTTP_ACCEPT_LANGUAGE
Language setting for the browser.
en-us,en;q=0.5
-
HTTP_CONNECTION
close
-
HTTP_HOST
unhinfo.unh.edu
-
HTTP_REFERER
The URL of the document that the client points to
before accessing this page or script.
(none)
-
HTTP_USER_AGENT
The browser identification string.
CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
-
LAST_MODIFIED
Last modification date of the requested document.
August 17, 1999
-
PATH
/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin
-
PATH_INFO
Extra path information, as given by the client,
for decoding by the server before passing to a CGI script.
(none)
-
PATH_TRANSLATED
The PATH_INFO after the server does any virtual to physical
mapping of it.
(none)
-
QUERY_STRING
Information which follows the "?" in the
URL referencing a script.
-
REMOTE_ADDR
The IP adddress of the remote host making the request.
38.103.63.61
-
REMOTE_PORT
52939
-
REMOTE_HOST
Host name making the request to the server.
(none)
-
REMOTE_IDENT
If the HTTP server supports
RFC 931 identification
then this variable will be set to the
remote user name retrieved from the server.
(none)
-
REMOTE_USER
If the server supports user authentication, and the
script is protected, this is the username they have
authenticated as.
(none)
-
REQUEST_URI
The file identifier requested.
/NIS/Courses/SSI/environ-vars.html
-
REQUEST_METHOD
Method of request, which for HTTP is GET, HEAD, or POST.
GET
-
SCRIPT_FILE_NAME
(none)
-
SCRIPT_NAME
Virtual path to the script being executed, used
for self-referencing URLs.
/NIS/Courses/SSI/environ-vars.html
-
SCRIPT_URI
http://unhinfo.unh.edu/NIS/Courses/SSI/environ-vars.html
-
SCRIPT_URL
/NIS/Courses/SSI/environ-vars.html
-
SERVER_ADMIN
E-mail address of the server sysadmin.
cwis.admin@unh.edu
-
SERVER_NAME
Server's hostname, DNS alias, or IP address as appearing
in self-referencing URLs.
unhinfo.unh.edu
-
SERVER_PORT
Server port for Web traffic (default=80).
80
-
SERVER_PROTOCOL
Name and revision of the information protocol this
request came in with.
HTTP/1.1
-
SERVER_SOFTWARE
Name and version of the server software.
Apache/2.0.52 (Red Hat)
-
USER_NAME
Process uname nder which the server software runs.
unhinfo
Return to
Courses page.
|