Variabili d’ambiente Apache ed estensioni SSI

Variabili d’ambiente di Apache

Ecco un elenco delle variabili d’ambiente Apache (Environmental Variables) e delle relative estensioni SSI (Server Side Includes).

Le variabili sono visualizzabili col comando echo di Apache o #printev di PHP.

Attenzione, i nomi delle varibili sono case sensitive.

GATEWAY_INTERFACE

Versione e revisione delle specifiche CGI che il server supporta.

Esempio: 
GATEWAY_INTERFACE=CGI/1.1 

PATH

I percorsi disponibili sul server per il sito web di riferimento

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

QUERY_STRING

Le eventuali informazioni inviate in querystring.

Esempio: 
chiamando h**ttp://ilmiosito.it?parola=ciao&valore=10 si ha
QUERY_STRING=parola=ciao&valore=10 si ha

REMOTE_ADDR

Restituisce l’indirizzo IP dell’host che sta realizzando la richiesta.

Esempio: 
REMOTE_ADDR=207.35.76.27 

REMOTE_PORT

Il numero di porta usato dall’host remoto che realizza la richiesta

Esempio:

REMOTE_PORT=4325 

REQUEST_METHOD

Il metodo usato dall’host remoto che realizza la richiesta (GET, HEAD, POST)

Esempio:

REQUEST_METHOD=POST 

REQUEST_URI

La URI della richiesta (relativamente alla DOCUMENT_ROOT)

Esempio: 
REQUEST_URI=/vs/web/variabili.htm 

SCRIPT_FILENAME

Il percorso dello script in esecuzione(relativamente alla DOCUMENT_ROOT)

Esempio:

SCRIPT_FILENAME=/tech/web/ssi.htm 

SCRIPT_NAME

Il nome dello script in esecuzione(relativamente alla DOCUMENT_ROOT)

Esempio:

SCRIPT_NAME=/tech/web/ssi.htm 

SERVER_ADDR

L’indirizzo IP del server dell’URL chiamato

Esempio: 

SERVER_ADDR=207.35.76.24

SERVER_ADMIN

L’indirizzo email dell’amministratore del server

Esempio:  
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 e.g.

SERVER_NAME=www.zytrax.com

SERVER_PORT

The port number on this server to which this request was directed e.g.

SERVER_PORT=80

SERVER_PROTOCOL

The name and revision of the protocol that delivered the current request e.g.

SERVER_PROTOCOL=HTTP/1.1

SERVER_SIGNATURE

The HTML string that may be embedded in the page to identify this host e.g.

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 e.g.

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 e.g.

HTTP_ACCEPT=*/*

HTTP_ACCEPT_ENCODING

The MIME types the requestor will accept as defined in the HTTP header e.g.

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 e.g.

HTTP_ACCEPT_LANGUAGE=en-us

HTTP_CONNECTION

The type of connection as defined in the HTTP header e.g.

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 e.g.

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 e.g.

DOCUMENT_ROOT=/var/www/zytrax

DOCUMENT_NAME

The file name (excludes directories) of the document requested by the user e.g.

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 e.g.

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 e.g.

USER_NAME=zytrax