Cheap Website Design, Hosting and Domain Names

Professional Websites-NGOs, Business, Travel Companies, Schools, Churches, Hotels and all others

Common Gateway Interface

The Common Gateway Interface (CGI) is a standard that defines how webserver software can delegate the generation of webpages to a text-based application. Such applications are known as CGI scripts; they can be written in any programming language, although scripting languages are often used. In simple words the CGI provides an interface between the webservers and the clients.


The task of a webserver is to respond to requests for webpages issued by clients (usually web browsers) by analyzing the content of the request (which is mostly in its URL), determining an appropriate document to send in response, and returning it to the client.

If the request identifies a file on disk, the server can just return the file's contents. Alternatively, the document's content can be composed on the fly. One way of doing this is to let a console application compute the document's contents, and tell the web server to use that console application. CGI specifies which information is communicated between the webserver and such a console application, and how.

The webserver software will invoke the console application as a command. CGI defines how information about the request (such as the URL) is passed to the command in the form of arguments and environment variables. The application is supposed to write the output document to standard output; CGI defines how it can pass back extra information about the output (such as the MIME type, which defines the type of document being returned) by prepending it with headers.

More info

From the Web server's point of view, certain locators, e.g., are defined as corresponding to a program to execute via CGI. When a request for the URL is received, the corresponding program is executed.

Web servers often have a cgi-bin/ directory at the base of their directory tree to hold executable files called with CGI.

nput data

Data is passed into the program using environment variables. This is in contrast to typical execution, where command-line arguments are used. In the case of HTTP PUT or POSTs, the user-submitted data is provided to the program via the standard input.[1]

The following environment variables pass to a CGI program:

Server specific variables

SERVER_SOFTWARE — name/version of HTTP server.
SERVER_NAME — host name of the server, may be dot-decimal IP address.

Request specific variables

SERVER_PORT — TCP port (decimal).
REQUEST_METHOD — name of HTTP method (see above).
PATH_INFO — path suffix, if appended to URL after program name and a slash.
PATH_TRANSLATED — corresponding full path as supposed by server, if PATH_INFO is present.
SCRIPT_NAME — relative path to the program, like /cgi-bin/script.cgi.
QUERY_STRING — the part of URL after ? character. Must be composed of name=value pairs separated with ampersands (such as var1=val1&var2=val2…) and used when form data are transferred via GET method.
REMOTE_HOST — host name of the client, unset if server did not perform such lookup.
REMOTE_ADDR — IP address of the client (dot-decimal).
AUTH_TYPE — identification type, if applicable.
REMOTE_USER used for certain AUTH_TYPEs.
REMOTE_IDENT — see ident, only if server performed such lookup.
CONTENT_TYPE — MIME type of input data if PUT or POST method are used, as provided via HTTP header.
CONTENT_LENGTH — similarly, size of input data (decimal, in octets) if provided via HTTP header.
Variables passed by user agent (HTTP_ACCEPT, HTTP_ACCEPT_LANGUAGE, HTTP_USER_AGENT, HTTP_COOKIE and possibly others) contain values of corresponding HTTP headers and therefore have the same sense.

Output format

The program returns the result to the web server in the form of standard output, prefixed by a header and a blank line.

The header is encoded in the same way as an HTTP header and must include the MIME type of the document returned.[2] The headers are generally forwarded with the response back to the user, supplemented by the web server.


An example of a CGI program is one implementing a wiki. The user agent requests the name of an entry; the server will retrieve the source of that entry's page (if one exists), transform it into HTML, and send the result.

Dynamic Websites

A dynamic web page is a kind of web page  that has been prepared with fresh information (content and/or layout), for each individual viewing. It is not static because it changes with the time (ex. a news content), the user (ex. preferences in a login session), the user interaction (ex. web page game), the context (parametric customization), or any combination of the foregoing.

Read more: Dynamic Websites

This Week
Last Week
This Month
Last Month
All days

Your IP:
Server Time: 2018-02-21 22:53:05

We have 18 guests and no members online

You are here: Home resources