Thursday, March 24, 2005

Server-side include commands for HTTP Server (powered by Apache) HTTP Server (powered by Apache) SSI commands have the following format:

Note: There is a space before -->. The parameter value is normally enclosed in double quotes, but for compatibility with the HTTP Server (original), double quotes are not required. The following describes the SSI commands for HTTP Server (powered by Apache).

echoThis command prints one of the SSI or API variables. Dates are printed using config timefmt. The attributes are:

var Specifies an environment variable name or CGI environment variable name. See the Environment variables on HTTP Server topic for a list of environment variables. For example:

encoding Specifies how the server encodes special characters contained in the variable. If set to none, no encoding is done. If set to url, then URL encoding (or %-encoding) is performed. If set to the default of entity, then entity encoding is performed. For example:

execThis command calls a CGI program. The attributes are:

cgi Specifies the relative path and file name. For example:

fsizeThis command prints the size of the specified file according to config sizefmt. The attributes are:

file Specifies the relative path and file name. For example:

virtual Specifies the relative path and file name using URL encoding. For example:

flastmodThis command prints the last modification date of the specified file according to config timefmt. The attributes are:

file Specifies the relative path and file name. For example:

virtual Specifies the relative path and file name using URL encoding. For example:

globalThis command is the same as the set command.

includeThis command inserts the text of another file. Included files can be nested. The attributes are:

file Specifies the relative path and file name. For example:

virtual Specifies the relative path and file name using URL encoding. For example:

printenvThis command prints all existing environment variables and their values. There are no attributes. For example:

setThis command sets the value of an environment variable. The attributes are:

value Specifies the value to assign to the environment variable name. For example:

If you want to insert a special character in a string, precede it with a \. For example:

Conditional commandsThere are four conditional or flow control commands. The if command tests a value. If the value is true, then processing continues with the next line. If the value is not true then processing continues with an elif, else, or endif command. The elif and else commands are optional. The if and elif commands have a parameter of expr. The expr parameter contains the test condition. An endif command is required for every if command. For example:

You are using Internet Explorer.

You are using Netscape.

You are not using Internet Explorer or Netscape.

The expr parameter can have one of the following forms:

Condition Comments string True if the string is not empty string1 = string2 (equal) Compare string1 with string2. If string2 has the form /string/, then it is compared as a regular expression. See Regular expression notation for HTTP Server for more information.

Test_condition1 && test_condition2 True if both test_condition1 and test_condition2 are true.

Test_condition1 || test_condition2 True if either test_condition1 or test_condition2 are true.

Variable substitution Values can be supplied in the following ways:

Test can be supplied within a quoted string. For example:

For compatibility with HTTP Server (original), text can be supplied without a quoted string. For example:

A literal dollar sign can be supplied in a string using a backslash. For example:

A variable reference can be supplied within a character sequence using braces. For example:

If REMOTE_HOST is equal to X and REQUEST_METHOD is equal to Y, then $ABC is equal to X_Y.

Note: For compatibility with HTTP Server (original), a variable name can also begin with an ampersand (&).Server-side include commands for HTTP Server (original) HTTP Server (original) SSI commands have the following format:

The quotes around value are optional. However, quotes are required for imbedding spaces.

The following describes the SSI commands.

cmntmsg Specifies the message appended to the beginning of any text that follows a directive specification and comes before -->. For example:

errmsg Specifies a message that is sent back to the client if an error occurs while parsing the document. The message is logged in the server's error log. The default value is [an error occurred while processing this directive]. For example:

sizefmt Specifies the format used to display the size of a file where bytes displays the file size in bytes or abbrev displays the file size in Kb or Mb. The default is abbrev. For example:

timefmt Specifies the format used to display dates and time. See Time formats for HTTP Server. The default is %a, %d %b-%Y %T %Z. For example:

The following describes the SSI commands for HTTP Server (original).

echoThis command prints one of the SSI or API variables. Dates are printed using config timefmt. The attributes are:

var Specifies an environment variable name or CGI environment variable name. See Environment variables on HTTP Server for a list of environment variables. For example:

execThis command includes the output of a CGI program. The exec command discards any HTTP headers CGI outputs except for the following:

fsize This command prints the size of the specified file according to config sizefmt. The attributes are:

file Specifies the relative path and file name. The file is assumed to be relative to the value contained in the SSI_ROOT environment variable if preceded by a /. If not preceded by a /, the file is assumed to be relative to the value of the SSI_DIR environment variable. For example:

virtual Specifies the relative path and file name using URL encoding. The virtual attribute is always passed through the mapping directives. For example:

flastmod This command prints the last modification time and date of the specified file according to config timefmt. The attributes are:

file Specifies the relative path and file name. The file is assumed to be relative to the value contained in the SSI_ROOT environment variable if preceded by a /. If not preceded by a /, the file is assumed to be relative to the value of the SSI_DIR environment variable. For example:

virtual Specifies the relative path and file name using URL encoding. The virtual attribute is always passed through the mapping directives. For example:

globalThis command sets the value of an environment variable that can be echoed by this file or any included files. The attributes are:

var Specifies an environment variable name. See Environment variables on HTTP Server for a list of environment variables.

value Specifies the value to assign to the environment variable name. For example, if you want to refer to a parent document across the virtual boundary, you need to set a global variable DOCUMENT_URI. You must also refer to the global variable in the child document. The following is an example of the coding you need to insert in the parent document:

The following is an example of the coding you need to insert into the child document:

includeThis command inserts the text of another file. Included files can be nested. The attributes are:

file Specifies the relative path and file name. The file is assumed to be relative to the value contained in the SSI_ROOT environment variable if preceded by a /. If not preceded by a /, the file is assumed to be relative to the value of the SSI_DIR environment variable. For example:

virtual Specifies the relative path and file name using URL encoding. The virtual attribute is always passed through the mapping directives. For example:

setThis command sets the value of an environment variable that only this file can echo later. Nothing is displayed if an unrecognized variable is found. The attributes are:

var Specifies an environment variable name. See Environment variables on HTTP Server for a list of environment variables.

value Specifies the value to assign to the environment variable name. For example:

If you want to insert a special character in a string, precede it with a \. For example:

Additional notesServer-side includes look for the variable, echoes where the variable is found, and proceeds with the function. You can have multiple variable references. When server-side includes encounter a variable reference inside a server-side include directive, it attempts to resolve it on the server side. The following example escapes the & so that server-side includes do not recognize it as a variable. In the second line of the example, the variable "&index" is a server-side variable and is used to construct the variable name "var1". The variable ê is a client side variable, so the & is escaped to create the value ":frêd" or "fred" with a circumflex over the e.

The following characters can be escaped. Escape variables must be preceded with a backslash (\).