346N/A<!
DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
346N/A<
TITLE>Apache module mod_include</
TITLE>
346N/A<
H1>Module mod_include</
H1>
346N/Ais compiled in by default. It provides for server-parsed html
346N/Adocuments, known as SPML documents. Any document with mime type
346N/Awith the resulting output given the mime type <
code>
text/
html</
code>.
346N/ASeveral directives beyond the original NCSA SPML definition have been
346N/Aincluded in Apache 1.2 - these are flagged below with the phrase
346N/A"Apache 1.2 and above". Of particular significance are the new flow
346N/Acontrol directives documented at the bottom.
346N/AThe document is parsed as an HTML document, with special commands embedded
346N/Aas SGML comments. A command has the syntax:
346N/A<!--#</
code><
em>element attribute=value attribute=value ...</
em> <
code>-->
346N/AThe value will often be enclosed in double quotes; many commands only allow
346N/Aa single attribute-value pair.
346N/AThe allowed elements are:<
p>
346N/A<
dt><
strong>config</
strong>
346N/AThis command controls various aspects of the parsing. The valid attributes
346N/A<
dd>The value is a message that is sent back to the client if an error occurs
346N/Awhilst parsing the document.
346N/A<
dd>The value sets the format to be used which displaying the size of a file.
346N/AValid values are <
code>bytes</
code> for a count in bytes, or
346N/A<
code>abbrev</
code> for a count in Kb or Mb as appropriate.
346N/A<
dd>The value is a string to be used by the <
code>strftime(3)</
code> library
346N/Aroutine when printing dates.
<
dt><
strong>echo</
strong>
This command prints one of the include variables, defined below.
If the variable is unset, it is printed as <
code>(none)</
code>.
Any dates printed are subject to the currently configured <
code>timefmt</
code>.
<
dd>The value is the name of the variable to print.
<
dt><
strong>exec</
strong>
The exec command executes a given shell command or CGI script.
The IncludesNOEXEC <
A HREF="core.html#options">Option</
A> disables this command
completely. The valid attributes are:
The value specifies a (%-encoded) URL relative path to the CGI script.
If the path does not begin with a (/), then it is taken to be relative to
the current document. The document referenced by this path is invoked
as a CGI script, even if the server would not normally recognize it as
such. However, the directory containing the script must be enabled for
CGI scripts (with <
A HREF="mod_alias.html#scriptalias">ScriptAlias</
A>
or the ExecCGI <
A HREF="core.html#options">Option</
A>).<
p>
The CGI script is given the PATH_INFO and query string (QUERY_STRING) of the
original request from the client; these cannot be specified in the URL path.
The include variables will be available to the script in addition to the
If the script returns a Location: header instead of output, then this
will be translated into an HTML anchor.<
p>
The <
code>include virtual</
code> element should be used in preference to
<
dd>The server will execute the given string using <
code>/
bin/
sh</
code>.
The include variables are available to the command.
<
dt><
strong>fsize</
strong>
This command prints the size of the specified file, subject to the
<
code>sizefmt</
code> format specification. Attributes:
<
dd>The value is a path relative to the directory containing the current
<
dd>The value is a (%-encoded) URL-path relative to the current document being
parsed. If it does not begin with a slash (/) then it is taken to be relative
<
dt><
strong>flastmod</
strong>
This command prints the last modification date of the specified file,
subject to the <
code>timefmt</
code> format specification. The attributes are
the same as for the <
code>fsize</
code> command.
<
dt><
strong>include</
strong>
This command inserts the text of another document or file into the parsed
file. Any included file is subject to the usual access control. If the
directory containing the parsed file has the
IncludesNOEXEC set, and the including the document would cause a program
to be executed, then it will not be included; this prevents the execution of
CGI scripts. Otherwise CGI scripts are invoked as normal using the complete
URL given in the command, including any query string.
<!--%plaintext <?INDEX CGI scripts, {\tt include} element and> --> An attribute defines the location of the document; the inclusion is done for
each attribute given to the include command. The valid attributes are:
<
dd>The value is a path relative to the directory containing the current
document being parsed. It cannot contain <
code>../</
code>, nor can it be an
absolute path. The <
code>virtual</
code> attribute should always be used
in preference to this one.
<
dd>The value is a (%-encoded) URL relative to the current document being
parsed. The URL cannot contain a scheme or hostname, only a path and
an optional query string. If it does not begin with a slash (/) then it
is taken to be relative to the current document.
A URL is constructed from the attribute, and the output the server
would return if the URL were accessed by the client is included in the parsed
output. Thus included files can be nested.
<
dt><
strong>printenv</
strong>
<
dd>This prints out a listing of all existing variables and their values.
<
dd>For example: <
code><!--#printenv --></
code>
<
dd>Apache 1.2 and above.
<
dd>This sets the value of a variable. Attributes:
<
dd>The name of the variable to set.
<
dd>The value to give a variable.
<
CODE><!--#set var="category" value="help"--></
CODE>
<
dd>Apache 1.2 and above.
<
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.
<
dd>The current date in Greenwich Mean Time.
<
dd>The current date in the local time zone.
<
dd>The filename (excluding directories) of the document requested by the
<
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
<
dd>The last modification date of the document requested by the user.
<
H2>Flow Control Elements</
H2>
These are available in Apache 1.2 and above. The basic flow control
<!--#if expr="<
I>test_condition</
I>" -->
<!--#elif expr="<
I>test_condition</
I>" -->
<
P> The <
B><
CODE>if</
CODE></
B> 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 <
B><
CODE>elif</
CODE></
B>, <
B><
CODE>else</
CODE></
B>.
or <
B><
CODE>endif</
CODE></
B> element is included in the
<
P> The <
B><
CODE>elif</
CODE></
B> or <
B><
CODE>else</
CODE></
B>
statements are be used the put text into the output stream
if the original test_condition was false. These elements
<
P> The <
B><
CODE>endif</
CODE></
B> element ends the
<
B><
CODE>if</
CODE></
B> element and is required.
<
P> <
I>test_condition</
I> is one of the following:
<
DT><
I>string</
I><
DD>true if <
I>string</
I> is not empty
<
DT><
I>string1</
I> = <
I>string2</
I><
BR>
<
I>string1</
I> != <
I>string2</
I>
<
DD>Compare string1 with string 2. If string2 has the form <
I>/string/</
I>
than it is compared as a regular expression.
Regular expressions have the same syntax as those found in the
<
DT>( <
I>test_condition</
I> )
<
DD>true if <
I>test_condition</
I> is true
<
DT>! <
I>test_condition</
I>
<
DD>true if <
I>test_condition</
I> is false
<
DT><
I>test_condition1</
I> && <
I>test_condition2</
I>
<
DD>true if both <
I>test_condition1</
I> and <
I>test_condition2</
I> are true
<
DT><
I>test_condition1</
I> || <
I>test_condition2</
I>
<
DD>true if either <
I>test_condition1</
I> or <
I>test_condition2</
I> is true
<
P> "<
I>=</
I>" and "</
I>!=</
I>" bind more tightly than "<
I>&&</
I>" and "<
I>||</
I>".
"<
I>!</
I>" binds most tightly. Thus, the following are equivalent:
<!--#if expr="$a = test1 && $b = test2" -->
<!--#if expr="($a = test1) && ($b = test2)" -->
<
P> Anything that's not recognized as a variable or an operator is
treated as a string. Strings can also be quoted: <
I>'string'</
I>.
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
<
I>string1 string2</
I> results in <
I>string1 string2</
I>
<
I>'string1 string2'</
I> results in <
I>string1 string2</
I>
<
P> Variable substitution is done within quoted strings. You can put
a dollar sign into the string using backslash quoting:
<!--#if expr="$a = \$test" -->
<
li><
A HREF="#xbithack">XBitHack</
A>
<
A name="xbithack"><
h2>XBitHack</
h2></
A>
<!--%plaintext <?INDEX {\tt XBitHack} directive> --> <
strong>Syntax:</
strong> XBitHack <
em>status</
em><
br>
<
strong>Default:</
strong> <
code>XBitHack off</
code><
br>
<
Strong>Context:</
strong> server config, virtual host, directory, .htaccess<
br>
<
Strong>Override:</
strong> Options<
br>
<
strong>Status:</
strong> Base<
br>
<
strong>Module:</
strong> mod_include<
p>
The XBitHack directives controls the parsing of ordinary html documents.
<
em>Status</
em> can have the following values:
<
dd>No special treatment of executable files.
<
dd>Any file that has the user-execute bit set will be treated as a
server-parsed html document.
<
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