Appendix B. CGI Environment Variables

Standard CGI Variables

Note that variables not defined by the CGI specification are marked with a star (). In addition, HTTP request header field values are added to the environment with the prefix HTTP_, and any hyphens in the header field name are changed to underscores (the Authorization and Proxy-Authorization headers are omitted for security reasons).

AUTH_TYPE

Authentication method used (only if request is subject to authentication)

CONTENT_LENGTH

Length of the entity body (for POST requests)

CONTENT_TYPE

MIME type of the entity body (for POST requests)

DOCUMENT_ROOT

Value of the DocumentRoot directive.

GATEWAY_INTERFACE

CGI version

PATH_INFO

URL part after script identifier (if present)

PATH_TRANSLATED

PATH_INFO translated into filesystem

QUERY_STRING

Query string from URL (if present)

REMOTE_ADDR

IP address of client

REMOTE_HOST

DNS name of client (if resolved)

REMOTE_IDENT

Remote user ID (unreliable, even if available)

REMOTE_USER

Name of the authenticated user (only if request is subject to authentication)

REQUEST_METHOD

HTTP request method

REQUEST_URI

URI of the request from the HTTP request line

SCRIPT_FILENAME

Full pathname of the script

SCRIPT_NAME

Virtual path ...

Get Apache 2 Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.