[an error occurred while processing this directive] [an error occurred while processing this directive] Tech Stuff - Apache Environmental Variables [an error occurred while processing this directive] [an error occurred while processing this directive]
[an error occurred while processing this directive]

Tech Stuff - Apache Environmental Variables

This section defines both the standard Apache Environmental Variables and the extended SSI Variables. Click to display them for our server using the #printenv function or the neat and tidy PHP version.

Notes:

  1. The names below are case sensitive.

  2. These variables are initialised when the request arrives and is passed to the SSI handler.

  3. If you need access to HTTP header variables then you need the services of mod_headers.

  4. Since Apache is the most popular web server what it does has become the de facto standard in the industry. Almost all web servers provide all the variables listed below.

GATEWAY_INTERFACE

The revision of the CGI specification this server supports, example:

GATEWAY_INTERFACE=CGI/1.1 

PATH

The PATH(s) available to the server for this web site, example:

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin 

QUERY_STRING

The information (if any) following the "?" in the URL for this request, for example, myform.html?a=b&c=d would provide

QUERY_STRING=a=b&c=d

Among other uses this is the format that forms use with the POST method to send data to the server.

Note: CGI variables are not initialised before calling SSI - they are not separated into discrete entries. Instead, you must access them as a 'raw' string using the $QUERY_STRING variable, for instance, in the above example expr="${a} = 'b'" DOES NOT WORK but expr="${QUERY_STRING} = /a=b/" DOES WORK.

Notes about QUERY_STRING Limits: By default Apache allows a maximum QUERY_STRING length of 8190 bytes. This value can be modified in two ways. At compile time by setting the variable DEFAULT_LIMIT_REQUEST_FIELDSIZE when Apache is built. At run time by setting the httpd.conf directives LimitRequestFieldsize (default of 8190 or the value of DEFAULT_LIMIT_REQUEST_FIELDSIZE if different) or LimitRequestLine (default 8190 or the value of DEFAULT_LIMIT_REQUEST_FIELDSIZE if different). Obviously when using the latter two directives the value cannot be increased beyond 8190 unless the compile time variable has also been increased.

REMOTE_ADDR

The IP address of the host making this request, example:

REMOTE_ADDR=207.35.76.27 

REMOTE_PORT

The port number used by the remote host when making this request, example:

REMOTE_PORT=4325 

REQUEST_METHOD

The method used for this request for HTTP "GET", HEAD" or "POST", example:

REQUEST_METHOD=GET 

REQUEST_URI

The URI for this request (relative to DOCUMENT_ROOT), example:

REQUEST_URI=/tech/web/ssi.htm 

SCRIPT_FILENAME

The path to the script being executed (relative to DOCUMENT_ROOT), example:

SCRIPT_FILENAME=/tech/web/ssi.htm 

SCRIPT_NAME

The file name of the script being executed (relative to DOCUMENT_ROOT), example:

SCRIPT_NAME=/tech/web/ssi.htm 

SERVER_ADDR

The IP address of the server for this URL, example:

SERVER_ADDR=207.35.76.24 

SERVER_ADMIN

The administrators e-mail address for this SERVER_NAME, example:

SERVER_ADMIN=webmaster@zytrax.com 

SERVER_NAME

The servers host name, DNS alias or IP address. For Apache the name appearing on the relevant ServerName directive (may be in the general section or a <virtualhost> section, example:

SERVER_NAME=www.zytrax.com 

SERVER_PORT

The port number on this server to which this request was directed, example:

SERVER_PORT=80 

SERVER_PROTOCOL

The name and revision of the protocol that delivered the current request, example:

SERVER_PROTOCOL=HTTP/1.1 

SERVER_SIGNATURE

The HTML string that may be embedded in the page to identify this host, example:

SERVER_SIGNATURE=<ADDRESS>Apache/1.3.14 Server at www.zytrax.com Port 80</ADDRESS> 

SERVER_SOFTWARE

The name and version of the information server answering the query, example:

SERVER_SOFTWARE=Apache/1.3.14 (Unix) (Red-Hat/Linux) PHP/4.0.3pl1

HTTP Header Variables

The following variables are constructed from the HTTP header information supplied by the requestor.

HTTP_ACCEPT

The MIME types the requestor will accept as defined in the HTTP header, example:

HTTP_ACCEPT=*/* 

HTTP_ACCEPT_ENCODING

The MIME types the requestor will accept as defined in the HTTP header, example:

HTTP_ACCEPT_ENCODING=gzip, deflate 

HTTP_ACCEPT_LANGUAGE

The LANGUAGE types the server is requested to accept as defined in the HTTP header and typically used for content negotiation, example:

HTTP_ACCEPT_LANGUAGE=en-us

HTTP_CONNECTION

The type of connection as defined in the HTTP header, example:

HTTP_CONNECTION=Keep-Alive 

HTTP_COOKIE

The value of any cookie in the HTTP header. Standard cookie formats are defined by RFC 2965 (Set-Cookie2 header) and the older (non-standard) netscape cookie format.

HTTP_HOST

The base URL of the host, example:

HTTP_HOST=www.zytrax.com 

HTTP_REFERER

The URL of the page that made this request. If linked from e-mail or manually entered this value is NULL.

HTTP_REFERER=http://www.zytrax.com/tech/web/ 

HTTP_USER_AGENT

The browser id or user-agent string identifying the browser (nominally defined by RFC 1945 and RFC 2068). See here for our current list.

HTTP_USER_AGENT=Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)

SSI Extensions

This section defines the additional variables made available by SSI.

DATE_GMT

The current date and time in Greenwich Mean Time (now Unviversal Co-ordinated Time (UCT) in the default or #config defined format).

DATE_GMT=Thursday, 03-May-2001 21:18:54 GMT 

DATE_LOCAL

The current date and time in the local (server) timezone (in the default or #config defined format).

DATE_LOCAL=Thursday, 03-May-2001 17:18:54 EDT 

DOCUMENT_ROOT

The root directory of this site defined by the 'DocumentRoot' directive in the General Section or a <virtualhost> section, example:

DOCUMENT_ROOT=/var/www/zytrax 

DOCUMENT_NAME

The file name (excludes directories) of the document requested by the user, example:

DOCUMENT_NAME=ssi.htm 

DOCUMENT_PATH_INFO

Not well documented, but it seems that if there is query string information following the URL (starts with a '?'), for instance, ../index.html?x=a, the data (x=a) is placed in QUERY_STRING. If the additional data starts with a /, for instance, ../index.html/path?x=a the data (path?x=a) is placed in the DOCUMENT_INFO_PATH variable. Apache 2.x allows the behaviour to be controlled using the AcceptPathInfo directive

DOCUMENT_PATH_INFO= 

DOCUMENT_URI

The URL path of the document requested by the user, example:

DOCUMENT_URI=/tech/web/ssi.htm 

LAST_MODIFIED

The last modification date of the document (file) requested by the user (in the default or #config defined format). This variable is not changed for SSI included files.

LAST_MODIFIED=Thursday, 03-May-2001 17:18:45 EDT

USER_NAME

The user name of the web site in which this web site runs, example:

USER_NAME=zytrax
[an error occurred while processing this directive]
[an error occurred while processing this directive]
[an error occurred while processing this directive] [an error occurred while processing this directive]
[an error occurred while processing this directive] [an error occurred while processing this directive]