mod_include.html revision c9aaa4cb1a852cad08fb47cf348f8c38332dc797
bcb4e51a409d94ae670de96afb8483a4f7855294Stephan Bosch<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<HTML>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<HEAD>
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen<TITLE>Apache module mod_include</TITLE>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen</HEAD>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<BODY
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen BGCOLOR="#FFFFFF"
156027ee3a689893bf22271d1cea8c97f9813cb9Timo Sirainen TEXT="#000000"
156027ee3a689893bf22271d1cea8c97f9813cb9Timo Sirainen LINK="#0000FF"
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen VLINK="#000080"
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen ALINK="#FF0000"
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<!--#include virtual="header.html" -->
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<H1 ALIGN="CENTER">Module mod_include</H1>
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen
dcb783533ad1d6944db7c227cde46414a575d81cTimo SirainenThis module is contained in the <CODE>mod_include.c</CODE> file, and
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainenis compiled in by default. It provides for server-parsed html
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainendocuments. Several directives beyond the original NCSA definition were
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainenintroduced in Apache 1.2 - these are flagged below with the phrase
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen"Apache 1.2 and above". Of particular significance are the new flow
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainencontrol directives documented at the bottom.
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen<H2>Enabling Server-Side Includes</H2>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
dcb783533ad1d6944db7c227cde46414a575d81cTimo SirainenAny document with handler of "server-parsed" will be parsed by this
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainenmodule, if the <CODE>Includes</CODE> option is set. If documents
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainencontaining server-side include directives are given the extension
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen.shtml, the following directives will make Apache parse them and
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenassign the resulting document the mime type of <CODE>text/html</CODE>:
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<PRE>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenAddType text/html .shtml
dcb783533ad1d6944db7c227cde46414a575d81cTimo SirainenAddHandler server-parsed .shtml
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen</PRE>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenThe following directive must be given for the directories containing
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainenthe shtml files (typically in a <CODE>&lt;Directory&gt;</CODE> section,
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainenbut this directive is also valid .htaccess files if <CODE>AllowOverride
dcb783533ad1d6944db7c227cde46414a575d81cTimo SirainenOptions</CODE> is set):
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen<PRE>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenOptions +Includes
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen</PRE>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenAlternatively the <A HREF="#xbithack"><CODE>XBitHack</CODE></A>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainendirective can be used to parse normal (<CODE>text/html</CODE>) files,
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenbased on file permissions. <P>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenFor backwards compatibility, documents with mime type
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<CODE>text/x-server-parsed-html</CODE> or
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<CODE>text/x-server-parsed-html3</CODE> will also be parsed
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen(and the resulting output given the mime type <CODE>text/html</CODE>).
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<H2>Basic Elements</H2>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenThe document is parsed as an HTML document, with special commands embedded
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenas SGML comments. A command has the syntax:
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<BLOCKQUOTE><CODE>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen&lt;!--#</CODE><EM>element attribute=value attribute=value ...</EM>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<CODE> --&gt;
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen</CODE></BLOCKQUOTE>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenThe value will often be enclosed in double quotes; many commands only allow
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainena single attribute-value pair. Note that the comment terminator
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen(<SAMP>--&gt;</SAMP>) should be preceded by whitespace to ensure that it
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenisn't considered part of an SSI token.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<P>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenThe allowed elements are:<P>
8b48c53a81bdc67f267ffbcc45ba9860cb49e977Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DL>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DT><STRONG>config</STRONG>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DD>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenThis command controls various aspects of the parsing. The valid attributes
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenare:
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DL>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DT>errmsg
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DD>The value is a message that is sent back to the client if an error occurs
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenwhilst parsing the document.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DT>sizefmt
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen<DD>The value sets the format to be used which displaying the size of a file.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenValid values are <CODE>bytes</CODE> for a count in bytes, or
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<CODE>abbrev</CODE> for a count in Kb or Mb as appropriate.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DT>timefmt
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen<DD>The value is a string to be used by the <CODE>strftime(3)</CODE> library
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainenroutine when printing dates.
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen</DL>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DT><STRONG><a name="echo">echo</a></STRONG>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DD>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenThis command prints one of the include variables, defined below.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenIf the variable is unset, it is printed as <CODE>(none)</CODE>.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenAny dates printed are subject to the currently configured <CODE>timefmt</CODE>.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenAttributes:
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DL>
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen<DT>var
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DD>The value is the name of the variable to print.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DT>encoding
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DD>Specifies how Apache should encode special characters contained
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenin the variable before outputting them. If set to "none", no encoding
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenwill be done. If set to "url", then URL encoding (also known as
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen%-encoding; this is appropriate for use within URLs in links, etc.)
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenwill be performed. At the start of an <CODE>echo</CODE> element,
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenthe default is set to "entity", resulting in entity encoding (which
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainenis appropriate in the context of a block-level HTML element, eg.
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainena paragraph of text). This can be changed by adding an
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<CODE>encoding</CODE> attribute, which will remain in effect until
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainenthe next <CODE>encoding</CODE> attribute is encountered or the
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenelement ends, whichever comes first. Note that the
5ae97456417a137a85c236a3db32f51fb592e474Timo Sirainen<CODE>encoding</CODE> attribute must <EM>precede</EM> the corresponding
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<CODE>var</CODE> attribute to be effective, and that only special
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainencharacters as defined in the ISO-8859-1 character encoding will be
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenencoded. This encoding process may not have the desired result if
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainena different character encoding is in use.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenApache 1.3.12 and above; previous versions do no encoding.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen</DL>
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DT><STRONG>exec</STRONG>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DD>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenThe exec command executes a given shell command or CGI script.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenThe IncludesNOEXEC <A HREF="core.html#options">Option</A> disables this command
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainencompletely. The valid attributes are:
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DL>
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainen<DT>cgi
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DD>
dcb783533ad1d6944db7c227cde46414a575d81cTimo SirainenThe value specifies a (%-encoded) URL relative path to the CGI script.
dcb783533ad1d6944db7c227cde46414a575d81cTimo SirainenIf the path does not begin with a (/), then it is taken to be relative to
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainenthe current document. The document referenced by this path is invoked
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainenas a CGI script, even if the server would not normally recognize it as
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainensuch. However, the directory containing the script must be enabled for
dcb783533ad1d6944db7c227cde46414a575d81cTimo SirainenCGI scripts (with <A HREF="mod_alias.html#scriptalias">ScriptAlias</A>
dcb783533ad1d6944db7c227cde46414a575d81cTimo Sirainenor the ExecCGI <A HREF="core.html#options">Option</A>).<P>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenThe CGI script is given the PATH_INFO and query string (QUERY_STRING) of the
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenoriginal request from the client; these cannot be specified in the URL path.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenThe include variables will be available to the script in addition to the
5ae97456417a137a85c236a3db32f51fb592e474Timo Sirainenstandard <A HREF="mod_cgi.html">CGI</A> environment.<P>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenIf the script returns a Location: header instead of output, then this
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenwill be translated into an HTML anchor.<P>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenThe <CODE>include virtual</CODE> element should be used in preference to
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<CODE>exec cgi</CODE>.
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DT>cmd
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DD>The server will execute the given string using <CODE>/bin/sh</CODE>.
37dfa8907f8216aa73e3880f3f98aba634458e42Timo SirainenThe include variables are available to the command.
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen</DL>
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DT><STRONG>fsize</STRONG>
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DD>
37dfa8907f8216aa73e3880f3f98aba634458e42Timo SirainenThis command prints the size of the specified file, subject to the
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<CODE>sizefmt</CODE> format specification. Attributes:
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DL>
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DT>file
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DD>The value is a path relative to the directory containing the current
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainendocument being parsed.
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DT>virtual
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DD>The value is a (%-encoded) URL-path relative to the current document being
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainenparsed. If it does not begin with a slash (/) then it is taken to be relative
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainento the current document.
8b48c53a81bdc67f267ffbcc45ba9860cb49e977Timo Sirainen</DL>
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen
8b48c53a81bdc67f267ffbcc45ba9860cb49e977Timo Sirainen<DT><STRONG>flastmod</STRONG>
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DD>
37dfa8907f8216aa73e3880f3f98aba634458e42Timo SirainenThis command prints the last modification date of the specified file,
8b48c53a81bdc67f267ffbcc45ba9860cb49e977Timo Sirainensubject to the <CODE>timefmt</CODE> format specification. The attributes are
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainenthe same as for the <CODE>fsize</CODE> command.
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DT><STRONG>include</STRONG>
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DD>
37dfa8907f8216aa73e3880f3f98aba634458e42Timo SirainenThis command inserts the text of another document or file into the parsed
c25abb52b05f4a7e380134ac21e7525d0b46187aTimo Sirainenfile. Any included file is subject to the usual access control. If the
c25abb52b05f4a7e380134ac21e7525d0b46187aTimo Sirainendirectory containing the parsed file has the
c25abb52b05f4a7e380134ac21e7525d0b46187aTimo Sirainen<A HREF="core.html#options">Option</A>
c25abb52b05f4a7e380134ac21e7525d0b46187aTimo SirainenIncludesNOEXEC set, and the including the document would cause a program
c25abb52b05f4a7e380134ac21e7525d0b46187aTimo Sirainento be executed, then it will not be included; this prevents the execution of
c25abb52b05f4a7e380134ac21e7525d0b46187aTimo SirainenCGI scripts. Otherwise CGI scripts are invoked as normal using the complete
c25abb52b05f4a7e380134ac21e7525d0b46187aTimo SirainenURL given in the command, including any query string.
c25abb52b05f4a7e380134ac21e7525d0b46187aTimo Sirainen<!--%plaintext &lt;?INDEX CGI scripts, {\tt include} element and&gt; -->
c25abb52b05f4a7e380134ac21e7525d0b46187aTimo Sirainen<P>
c25abb52b05f4a7e380134ac21e7525d0b46187aTimo Sirainen
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo SirainenAn attribute defines the location of the document; the inclusion is done for
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Siraineneach attribute given to the include command. The valid attributes are:
baf3e87e186453fda13bd21f7cbcb2efc8492e8bTimo Sirainen<DL>
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DT>file
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DD>The value is a path relative to the directory containing the current
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainendocument being parsed. It cannot contain <CODE>../</CODE>, nor can it be an
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenabsolute path. The <CODE>virtual</CODE> attribute should always be used
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenin preference to this one.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen<DT>virtual
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainen<DD>The value is a (%-encoded) URL relative to the current document being
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainenparsed. The URL cannot contain a scheme or hostname, only a path and
c25abb52b05f4a7e380134ac21e7525d0b46187aTimo Sirainenan optional query string. If it does not begin with a slash (/) then it
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainenis taken to be relative to the current document.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen</DL>
156027ee3a689893bf22271d1cea8c97f9813cb9Timo SirainenA URL is constructed from the attribute, and the output the server
37dfa8907f8216aa73e3880f3f98aba634458e42Timo Sirainenwould return if the URL were accessed by the client is included in the parsed
156027ee3a689893bf22271d1cea8c97f9813cb9Timo Sirainenoutput. Thus included files can be nested.
bf698b98d3a3a1eced66cc682c449f23bf2b67d0Timo Sirainen
<DT><STRONG>printenv</STRONG>
<DD>This prints out a listing of all existing variables and their values.
Starting with Apache 1.3.12, special characters are entity encoded (see the
<A HREF="#echo"><CODE>echo</CODE></A> element for details) before being
output. No attributes.
<DD>For example: <CODE>&lt;!--#printenv --&gt;</CODE>
<DD>Apache 1.2 and above.
<DT><STRONG>set</STRONG>
<DD>This sets the value of a variable. Attributes:
<DL>
<DT>var
<DD>The name of the variable to set.
<DT>value
<DD>The value to give a variable.
</DL>
For example:
<CODE>&lt;!--#set var="category" value="help" --&gt;</CODE>
<DD>Apache 1.2 and above.
</DL>
<H2>Include Variables</H2>
In addition to the variables in the standard CGI environment, these are
available for the <CODE>echo</CODE> command, for <CODE>if</CODE> and
<CODE>elif</CODE>, and to any program invoked by the document.
<DL>
<DT>DATE_GMT
<DD>The current date in Greenwich Mean Time.
<DT>DATE_LOCAL
<DD>The current date in the local time zone.
<DT>DOCUMENT_NAME
<DD>The filename (excluding directories) of the document requested by the
user.
<DT>DOCUMENT_URI
<DD>The (%-decoded) URL path of the document requested by the user. Note that
in the case of nested include files, this is <EM>not</EM> then URL for the
current document.
<DT>LAST_MODIFIED
<DD>The last modification date of the document requested by the user.
</DL>
<P>
<H2>Variable Substitution</H2>
<P> Variable substitution is done within quoted strings in most cases
where they may reasonably occur as an argument to an SSI directive.
This includes the
<SAMP>config</SAMP>,
<SAMP>exec</SAMP>,
<SAMP>flastmod</SAMP>,
<SAMP>fsize</SAMP>,
<SAMP>include</SAMP>, and
<SAMP>set</SAMP>
directives, as well as the arguments to conditional operators.
You can insert a literal dollar sign into the string using backslash
quoting:
<PRE>
&lt;!--#if expr="$a = \$test" --&gt;
</PRE>
<P> If a variable reference needs to be substituted in the middle of a
character sequence that might otherwise be considered a valid
identifier in its own right, it can be disambiguated by enclosing
the reference in braces, <EM>&agrave; la</EM> shell substitution:
<PRE>
&lt;!--#set var="Zed" value="${REMOTE_HOST}_${REQUEST_METHOD}" --&gt;
</PRE>
<P> This will result in the <SAMP>Zed</SAMP> variable being set to
&quot;<SAMP>X_Y</SAMP>&quot; if <SAMP>REMOTE_HOST</SAMP> is
&quot;<SAMP>X</SAMP>&quot; and <SAMP>REQUEST_METHOD</SAMP> is
&quot;<SAMP>Y</SAMP>&quot;.
<P> EXAMPLE: the below example will print "in foo" if the DOCUMENT_URI is
/foo/file.html, "in bar" if it is /bar/file.html and "in neither"
otherwise:
<PRE>
&lt;!--#if expr="\"$DOCUMENT_URI\" = \"/foo/file.html\"" --&gt;
in foo
&lt;!--#elif expr="\"$DOCUMENT_URI\" = \"/bar/file.html\"" --&gt;
in bar
&lt;!--#else --&gt;
in neither
&lt;!--#endif --&gt;
</PRE>
<H2><A NAME="flowctrl">Flow Control Elements</A></H2>
These are available in Apache 1.2 and above. The basic flow control
elements are:
<PRE>
&lt;!--#if expr="<EM>test_condition</EM>" --&gt;
&lt;!--#elif expr="<EM>test_condition</EM>" --&gt;
&lt;!--#else --&gt;
&lt;!--#endif --&gt;
</PRE>
<P> The <STRONG><CODE>if</CODE></STRONG> element works like an
if statement in a programming language. The test condition
is evaluated and if the result is true, then the text until
the next <STRONG><CODE>elif</CODE></STRONG>, <STRONG><CODE>else</CODE></STRONG>.
or <STRONG><CODE>endif</CODE></STRONG> element is included in the
output stream.
<P> The <STRONG><CODE>elif</CODE></STRONG> or <STRONG><CODE>else</CODE></STRONG>
statements are be used the put text into the output stream
if the original test_condition was false. These elements
are optional.
<P> The <STRONG><CODE>endif</CODE></STRONG> element ends the
<STRONG><CODE>if</CODE></STRONG> element and is required.
<P> <EM>test_condition</EM> is one of the following:
<DL>
<DT><EM>string</EM><DD>true if <EM>string</EM> is not empty
<DT><EM>string1</EM> = <EM>string2</EM>
<BR>
<EM>string1</EM> != <EM>string2</EM>
<BR>
<EM>string1</EM> &lt; <EM>string2</EM>
<BR>
<EM>string1</EM> &lt;= <EM>string2</EM>
<BR>
<EM>string1</EM> &gt; <EM>string2</EM>
<BR>
<EM>string1</EM> &gt;= <EM>string2</EM>
<DD>Compare string1 with string 2. If string2 has the form <EM>/string/</EM>
then it is compared as a regular expression.
Regular expressions have the same syntax as those found in the
Unix <SAMP>egrep</SAMP> command.
<DT>( <EM>test_condition</EM> )
<DD>true if <EM>test_condition</EM> is true
<DT>! <EM>test_condition</EM>
<DD>true if <EM>test_condition</EM> is false
<DT><EM>test_condition1</EM> && <EM>test_condition2</EM>
<DD>true if both <EM>test_condition1</EM> and
<EM>test_condition2</EM> are true
<DT><EM>test_condition1</EM> || <EM>test_condition2</EM>
<DD>true if either <EM>test_condition1</EM> or
<EM>test_condition2</EM> is true
</DL>
<P> "<EM>=</EM>" and "<EM>!=</EM>" bind more tightly than "<EM>&&</EM>" and
"<EM>||</EM>".
"<EM>!</EM>" binds most tightly. Thus, the following are equivalent:
<PRE>
&lt;!--#if expr="$a = test1 && $b = test2" --&gt;
&lt;!--#if expr="($a = test1) && ($b = test2)" --&gt;
</PRE>
<P> Anything that's not recognized as a variable or an operator is
treated as a string. Strings can also be quoted: <EM>'string'</EM>.
Unquoted strings can't contain whitespace (blanks and tabs)
because it is used to separate tokens such as variables. If
multiple strings are found in a row, they are concatenated using
blanks. So,
<PRE>
<EM>string1 string2</EM> results in <EM>string1 string2</EM>
<EM>'string1 string2'</EM> results in <EM>string1 string2</EM>
</PRE>
<HR>
<H2>Directives</H2>
<UL>
<LI><A HREF="#xbithack">XBitHack</A>
</UL>
<HR>
<H2><A NAME="xbithack">XBitHack</A></H2>
<!--%plaintext &lt;?INDEX {\tt XBitHack} directive&gt; -->
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> XBitHack <EM>status</EM><BR>
<A
HREF="directive-dict.html#Default"
REL="Help"
><STRONG>Default:</STRONG></A> <CODE>XBitHack off</CODE><BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
<A
HREF="directive-dict.html#Override"
REL="Help"
><STRONG>Override:</STRONG></A> Options<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_include<P>
The XBitHack directives controls the parsing of ordinary html documents.
This directive only affects files associated with the MIME type
<CODE>text/html</CODE>.
<EM>Status</EM> can have the following values:
<DL>
<DT>off
<DD>No special treatment of executable files.
<DT>on
<DD>Any file that has the user-execute bit set will be treated as a
server-parsed html document.
<DT>full
<DD>As for <CODE>on</CODE> but also test the group-execute bit. If it
is set, then set the Last-modified date of the returned file to be the
last modified time of the file. If it is not set, then no last-modified date
is sent. Setting this bit allows clients and proxies to cache the result of
the request.
<P><STRONG>Note:</STRONG> you would not want to use this, for example, when you
<CODE>#include</CODE> a CGI that produces different output on each hit
(or potentially depends on the hit).
</DL>
<P>
<HR>
<H2>Using Server Side Includes for ErrorDocuments</H2>
There is <A HREF="/misc/custom_errordocs.html">a document</A> which
describes how to use the features of mod_include to offer internationalized
customized server error documents.
<P>
<!--#include virtual="footer.html" -->
</BODY>
</HTML>