CGI environment variables

Before running a CGI application or interpreter, Abyss Web Server sets its environment variables in conformity with the CGI/1.1 specification (as described in and adds variables declared in the Custom Environment Variables table as well as the system environment variables. Some Abyss Web Server specific variables are also set.

The following list contains the variables documented in the CGI/1.1 specification and some variables commonly set by web servers:

If the current request is served by an SSL enabled host, the following SSL related variables are also available:

The Abyss Web Server specific variables provide a means to access to server and host statistics. They are listed below:

In addition to these variables, all header lines received in the request are added to the environment with the prefix HTTP_ followed by the header name in upper cases. All - characters in the header name are changed to underscore _ characters. For example, User-Agent is translated to HTTP_USER_AGENT.

If the request results from an internal redirection (from an XSSI document or if it is used as a custom error page for example), the environment variables of the parent request are also added and each variable name is prefixed by REDIRECT_. The parent request's status code is stored in the special variables REDIRECT_STATUS and REDIRECT_STATUS_CODE. The cookies of the parent request are also passed to the redirected request in the COOKIES environment variable. REDIRECT_STATUS_CODE may seem redundant but it is actually useful when with PHP scripts as some PHP configurations require setting REDIRECT_STATUS to a fixed value.

Example 6-1. Using the redirection information in scripts

If a script is invoked after an internal redirection, it can retrieve some interesting information from the environment about its parent request such as:

Note: The CGI environment variables are not only useful for CGI applications and interpreters. They are also available and used in XSSI pages and ISAPI interpreters and applications.