CGI Environment Variables
by: G.E. Ozz Nixon Jr.
Published: June 2009
©opyright 2009 by Friends of FPC
The following list contains the variables documented in the CGI/1.1 specification and some variables commonly set by web servers:
PATH_INFO: The extra path information, as given in the requested URL. In fact, scripts can be accessed by their virtual path, followed by extra information at the end of this path. The extra information is sent in PATH_INFO.
PATH_TRANSLATED: The virtual-to-real mapped version of PATH_INFO.
SCRIPT_NAME: The virtual path of the script being executed.
SCRIPT_FILENAME and
REQUEST_FILENAME: The real path of the script being executed.
SCRIPT_URI: The full URL to the current object requested by the client.
URL: The full URI of the current request. It is made of the concatenation of SCRIPT_NAME and PATH_INFO (if available.)
SCRIPT_URL and
REQUEST_URI: The original request URI sent by the client.
REQUEST_METHOD: The method used by the current request; usually set to GET or POST.
QUERY_STRING: The information which follows the ? character in the requested URL.
CONTENT_TYPE: The MIME type of the request body; set only for POST or PUT requests.
CONTENT_LENGTH: The length in bytes of the request body; set only for POST or PUT requests.
AUTH_TYPE: The authentication type if the client has authenticated itself to access the script.
AUTH_USER and
REMOTE_USER: The name of the user as issued by the client when authenticating itself to access the script.
ALL_HTTP: All HTTP headers sent by the client. Headers are separated by carriage return characters (ASCII 13 - \n) and each header name is prefixed by HTTP_, transformed to upper cases, and - characters it contains are replaced by _ characters.
ALL_RAW: All HTTP headers as sent by the client in raw form. No transformation on the header names is applied.
SERVER_SOFTWARE: The web server's software identity.
SERVER_NAME: The host name or the IP address of the computer running the web server as given in the requested URL.
SERVER_PORT: The port to which the request was sent.
GATEWAY_INTERFACE: The CGI Specification version supported by the web server; always set to CGI/1.1.
SERVER_PROTOCOL: The HTTP protocol version used by the current request.
REMOTE_ADDR: The IP address of the computer that sent the request.
REMOTE_PORT: The port from which the request was sent.
DOCUMENT_ROOT: The absolute path of the web site files. It has the same value as Documents Path.
INSTANCE_ID: The numerical identifier of the host which served the request.
APPL_MD_PATH: The virtual path of the deepest alias which contains the request URI. If no alias contains the request URI, the variable is set to /.
APPL_PHYSICAL_PATH: The real path of the deepest alias which contains the request URI. If no alias contains the request URI, the variable is set to the same value as DOCUMENT_ROOT.
IS_SUBREQ: It is set to true if the current request is a subrequest, i.e. a request not directly invoked by a client. Otherwise, it is set to true. Subrequests are generated by the server for internal processing. XSSI includes for example result in subrequests.
If the current request is served by an SSL enabled host, the following SSL related variables are also available:
SSL_PROTOCOL: The SSL protocol version. It could be SSLv2, SSLv3, or TLSv1.
SSL_CIPHER and
HTTPS_CIPHER: The SSL protocol version. It could be SSLv2, SSLv3, or TLSv1.
SSL_CIPHER_EXPORT: It is set to true if the cipher is conforming to US export restrictions (i.e. it is limited to 56 bit symmetric keys and 1024 asymmetric keys).
SSL_CIPHER_USEKEYSIZE and
HTTPS_SECRETKEYSIZE: The number of cipher bits currently used.
SSL_CIPHER_ALGKEYSIZE and
HTTPS_KEYSIZE: The maximum number of cipher bits that could be used.
SSL_SERVER_M_VERSION: The version of the server's certificate.
SSL_SERVER_M_SERIAL: The serial number of the server's certificate.
SSL_SERVER_V_START: The date corresponding to the start of the validity the server's certificate.
SSL_SERVER_V_END: The date corresponding to the end of the validity the server's certificate.
SSL_SERVER_A_SIG: The algorithm used to sign the server's certificate.
SSL_SERVER_A_KEY: The encryption type of the private key of the server's certificate.
SSL_SERVER_S_DN and
HTTPS_SERVER_SUBJECT: The value of the subject's DN (distinguished name) of the server's certificate.
SSL_SERVER_S_DN_component: The value of the component of the subject's DN (distinguished name) of the server's certificate. component can be CN (Common Name), C (Country), ST or SP (State/Province), L (Locality), O (Organization), OU (Organization Unit), T (Title), I (Initials), G (Given Name), S (Surname), D (Description), Email (Contact Email).
SSL_SERVER_I_DN and
HTTPS_SERVER_ISSUER: The value of the issuer's DN (distinguished name) of the server's certificate.
SSL_SERVER_I_DN_component: The value of the component of the issuer's DN (distinguished name) of the server's certificate. component can be CN (Common Name), C (Country), ST or SP (State/Province), L (Locality), O (Organization), OU (Organization Unit), T (Title), I (Initials), G (Given Name), S (Surname), D (Description), Email (Contact Email).