mod_include.html revision 2eaf662cbc81e823e8d9aeb8d54e69e63032493e
5f5870385cff47efd2f58e7892f251cf13761528Timo Sirainen<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen<html xmlns="http://www.w3.org/1999/xhtml">
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <head>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <meta name="generator" content="HTML Tidy, see www.w3.org" />
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen <title>Apache module mod_include</title>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen </head>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen vlink="#000080" alink="#FF0000">
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <!--#include virtual="header.html" -->
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <h1 align="CENTER">Module mod_include</h1>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <p>This module provides for server-parsed html documents.</p>
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <p><a href="module-dict.html#Status"
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen rel="Help"><strong>Status:</strong></a> Base<br />
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <a href="module-dict.html#SourceFile"
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen rel="Help"><strong>Source File:</strong></a>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen mod_include.c<br />
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <a href="module-dict.html#ModuleIdentifier"
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen rel="Help"><strong>Module Identifier:</strong></a>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen includes_module</p>
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <h2>Summary</h2>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen
eef4ba0cc3e78f8c26804c1c9251a76580a41f0cTimo Sirainen <p>This module provides a filter which will process files
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen before they are sent to the client. The processing is
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen controlled by specially formated SGML comments, referred to as
eef4ba0cc3e78f8c26804c1c9251a76580a41f0cTimo Sirainen <em>elements</em>. These elements allow conditional text, the
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen inclusion other files or programs, as well as the setting and
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen printing of environment variables.</p>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <h2>Directives</h2>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <ul>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <li><a href="#xbithack">XBitHack</a></li>
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen </ul>
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen <p>See also: <a href="core.html#options">Options</a> and <a
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen href="core.html.html#SetOutputFilter">SetOutputFilter</a>.</p>
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <h2>Enabling Server-Side Includes</h2>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen <p>Server Side Includes are implemented by the
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <code>INCLUDES</code> <a href="/filter.html">filter</a>. If
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen documents containing server-side include directives are given
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen the extension .shtml, the following directives will make Apache
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen parse them and assign the resulting document the mime type of
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen <code>text/html</code>:</p>
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen <blockquote>
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen <code>AddType text/html .shtml<br />
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen &lt;FilesMatch "\.shtml(\..+)?$"&gt;<br />
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen &nbsp;&nbsp;SetOutputFilter INCLUDES<br />
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen &lt;/FilesMatch&gt;</code>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen </blockquote>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <p>Be careful to properly scope the INCLUDES filter to process
12224fcf2de6724c89f63c0f9ee857f28a270df5Timo Sirainen only the correct files. The filter is <strong>not</strong>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen restricted to processing only HTML files. So, for example, if
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen the INCLUDES filter is activated using a
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <code>&lt;Directory&gt;</code> section and that directory
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen includes GIF files, mod_include will process the GIF files.
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen This can have two adverse consequences: 1. there will be extra
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen overhead in serving these files, and 2. these files could
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen become corrupted if they happen to contain something that looks
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen like an SSI element.</p>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <p>The following directive must be given for the directories
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen containing the shtml files (typically in a
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <code>&lt;Directory&gt;</code> section, but this directive is
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen also valid .htaccess files if <code>AllowOverride
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen Options</code> is set):</p>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <blockquote>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <code>Options +Includes</code>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen </blockquote>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <p>For backwards compatibility, the <code>server-parsed</code>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <a href="/handler.html">handler</a> also activates the
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen INCLUDES filter. As well, Apache will activate the INCLUDES
f77da594de6318312a7f31589c9e4c38e2b74c73Timo Sirainen filter for any document with mime type
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <code>text/x-server-parsed-html</code> or
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <code>text/x-server-parsed-html3</code> (and the resulting
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen output will have the mime type <code>text/html</code>).</p>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <p>For more information, see our <a
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen href="/howto/ssi.html">Tutorial on Server Side
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen Includes</a>.</p>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <h2>Basic Elements</h2>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen The document is parsed as an HTML document, with special
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen commands embedded as SGML comments. A command has the syntax:
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <blockquote>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <code>&lt;!--#</code><em>element attribute=value
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen attribute=value ...</em> <code>--&gt;</code>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen </blockquote>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen The value will often be enclosed in double quotes; many
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen commands only allow a single attribute-value pair. Note that
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen the comment terminator (<samp>--&gt;</samp>) should be preceded
f77da594de6318312a7f31589c9e4c38e2b74c73Timo Sirainen by whitespace to ensure that it isn't considered part of an SSI
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen token.
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <p>The allowed elements are:</p>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dl>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dt><strong>config</strong></dt>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dd>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen This command controls various aspects of the parsing. The
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen valid attributes are:
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dl>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dt>errmsg</dt>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dd>The value is a message that is sent back to the
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen client if an error occurs whilst parsing the
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen document.</dd>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dt>sizefmt</dt>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dd>The value sets the format to be used which displaying
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen the size of a file. Valid values are <code>bytes</code>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen for a count in bytes, or <code>abbrev</code> for a count
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen in Kb or Mb as appropriate.</dd>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dt>timefmt</dt>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dd>The value is a string to be used by the
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <code>strftime(3)</code> library routine when printing
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen dates.</dd>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen </dl>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen </dd>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dt><strong><a id="echo" name="echo">echo</a></strong></dt>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dd>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen This command prints one of the include variables, defined
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen below. If the variable is unset, it is printed as
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <code>(none)</code>. Any dates printed are subject to the
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen currently configured <code>timefmt</code>. Attributes:
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
f77da594de6318312a7f31589c9e4c38e2b74c73Timo Sirainen <dl>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dt>var</dt>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dd>The value is the name of the variable to print.</dd>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dt>encoding</dt>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dd>Specifies how Apache should encode special characters
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen contained in the variable before outputting them. If set
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen to "none", no encoding will be done. If set to "url",
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen then URL encoding (also known as %-encoding; this is
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen appropriate for use within URLs in links, etc.) will be
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen performed. At the start of an <code>echo</code> element,
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen the default is set to "entity", resulting in entity
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen encoding (which is appropriate in the context of a
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen block-level HTML element, eg. a paragraph of text). This
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen can be changed by adding an <code>encoding</code>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen attribute, which will remain in effect until the next
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <code>encoding</code> attribute is encountered or the
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen element ends, whichever comes first. Note that the
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <code>encoding</code> attribute must <em>precede</em> the
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen corresponding <code>var</code> attribute to be effective,
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen and that only special characters as defined in the
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen ISO-8859-1 character encoding will be encoded. This
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen encoding process may not have the desired result if a
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen different character encoding is in use. Apache 1.3.12 and
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen above; previous versions do no encoding.</dd>
f77da594de6318312a7f31589c9e4c38e2b74c73Timo Sirainen </dl>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen </dd>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dt><strong>exec</strong></dt>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dd>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen The exec command executes a given shell command or CGI
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen script. The IncludesNOEXEC <a
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen href="core.html#options">Option</a> disables this command
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen completely. The valid attributes are:
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dl>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dt>cgi</dt>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <dd>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen The value specifies a (%-encoded) URL relative path to
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen the CGI script. If the path does not begin with a (/),
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen then it is taken to be relative to the current
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen document. The document referenced by this path is
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen invoked as a CGI script, even if the server would not
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen normally recognize it as such. However, the directory
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen containing the script must be enabled for CGI scripts
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen (with <a
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen href="mod_alias.html#scriptalias">ScriptAlias</a> or
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen the ExecCGI <a href="core.html#options">Option</a>).
b3126bef7460052415eea07b300d02c8eb07c1d7Timo Sirainen
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen <p>The CGI script is given the PATH_INFO and query
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen string (QUERY_STRING) of the original request from the
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen client; these cannot be specified in the URL path. The
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen include variables will be available to the script in
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen addition to the standard <a href="mod_cgi.html">CGI</a>
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen environment.</p>
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen <p>If the script returns a Location: header instead of
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen output, then this will be translated into an HTML
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen anchor.</p>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen <p>The <code>include virtual</code> element should be
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen used in preference to <code>exec cgi</code>.</p>
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen </dd>
4eecd3e2aadb20768a60f701e329b4345d04430cTimo Sirainen
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainen <dt>cmd</dt>
b932ee7fbbec6e79b777dcc7ba613b9e99f8337bTimo Sirainen
b932ee7fbbec6e79b777dcc7ba613b9e99f8337bTimo Sirainen <dd>The server will execute the given string using
b932ee7fbbec6e79b777dcc7ba613b9e99f8337bTimo Sirainen <code>/bin/sh</code>. The include variables are available
b932ee7fbbec6e79b777dcc7ba613b9e99f8337bTimo Sirainen to the command.</dd>
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen </dl>
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen </dd>
b932ee7fbbec6e79b777dcc7ba613b9e99f8337bTimo Sirainen
b932ee7fbbec6e79b777dcc7ba613b9e99f8337bTimo Sirainen <dt><strong>fsize</strong></dt>
b932ee7fbbec6e79b777dcc7ba613b9e99f8337bTimo Sirainen
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen <dd>
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen This command prints the size of the specified file, subject
5fbccc935e3f7b916aa7c6e302a212821072e83aTimo Sirainen to the <code>sizefmt</code> format specification.
b932ee7fbbec6e79b777dcc7ba613b9e99f8337bTimo Sirainen Attributes:
b932ee7fbbec6e79b777dcc7ba613b9e99f8337bTimo Sirainen
b932ee7fbbec6e79b777dcc7ba613b9e99f8337bTimo Sirainen <dl>
1db62753d9e3b5d71018889c8ef0a3722a307455Timo Sirainen <dt>file</dt>
23878bd03d1de531e3261a25598beec621351910Timo Sirainen
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainen <dd>The value is a path relative to the directory
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainen containing the current document being parsed.</dd>
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainen
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainen <dt>virtual</dt>
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainen
b932ee7fbbec6e79b777dcc7ba613b9e99f8337bTimo Sirainen <dd>The value is a (%-encoded) URL-path relative to the
23878bd03d1de531e3261a25598beec621351910Timo Sirainen current document being parsed. If it does not begin with
23878bd03d1de531e3261a25598beec621351910Timo Sirainen a slash (/) then it is taken to be relative to the
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen current document.</dd>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen </dl>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen </dd>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <dt><strong>flastmod</strong></dt>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <dd>This command prints the last modification date of the
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen specified file, subject to the <code>timefmt</code> format
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen specification. The attributes are the same as for the
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <code>fsize</code> command.</dd>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <dt><strong>include</strong></dt>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <dd>
23878bd03d1de531e3261a25598beec621351910Timo Sirainen This command inserts the text of another document or file
23878bd03d1de531e3261a25598beec621351910Timo Sirainen into the parsed file. Any included file is subject to the
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen usual access control. If the directory containing the
23878bd03d1de531e3261a25598beec621351910Timo Sirainen parsed file has the <a href="core.html#options">Option</a>
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen IncludesNOEXEC set, and the including the document would
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen cause a program to be executed, then it will not be
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen included; this prevents the execution of CGI scripts.
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen Otherwise CGI scripts are invoked as normal using the
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen complete URL given in the command, including any query
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen string.
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainen <!--%plaintext &lt;?INDEX CGI scripts, {\tt include} element and&gt; -->
23878bd03d1de531e3261a25598beec621351910Timo Sirainen
23878bd03d1de531e3261a25598beec621351910Timo Sirainen
1a3f9d72e15fb931edf58f104fb7ff12d238f051Timo Sirainen <p>An attribute defines the location of the document; the
23878bd03d1de531e3261a25598beec621351910Timo Sirainen inclusion is done for each attribute given to the include
command. The valid attributes are:</p>
<dl>
<dt>file</dt>
<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>
<dt>virtual</dt>
<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.</dd>
</dl>
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.
</dd>
<dt><strong>printenv</strong></dt>
<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>
<dd>For example: <code>&lt;!--#printenv --&gt;</code></dd>
<dd>Apache 1.2 and above.</dd>
<dt><strong>set</strong></dt>
<dd>
This sets the value of a variable. Attributes:
<dl>
<dt>var</dt>
<dd>The name of the variable to set.</dd>
<dt>value</dt>
<dd>The value to give a variable.</dd>
</dl>
For example: <code>&lt;!--#set var="category" value="help"
--&gt;</code>
</dd>
<dd>Apache 1.2 and above.</dd>
</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</dt>
<dd>The current date in Greenwich Mean Time.</dd>
<dt>DATE_LOCAL</dt>
<dd>The current date in the local time zone.</dd>
<dt>DOCUMENT_NAME</dt>
<dd>The filename (excluding directories) of the document
requested by the user.</dd>
<dt>DOCUMENT_URI</dt>
<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.</dd>
<dt>LAST_MODIFIED</dt>
<dd>The last modification date of the document requested by
the user.</dd>
</dl>
<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:</p>
<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:</p>
<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 "<samp>X_Y</samp>" if <samp>REMOTE_HOST</samp> is
"<samp>X</samp>" and <samp>REQUEST_METHOD</samp> is
"<samp>Y</samp>".</p>
<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:</p>
<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 id="flowctrl" 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>
<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>
<p>The <strong><code>endif</code></strong> element ends the
<strong><code>if</code></strong> element and is required.</p>
<p><em>test_condition</em> is one of the following:</p>
<dl>
<dt><em>string</em></dt>
<dd>true if <em>string</em> is not empty</dd>
<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></dt>
<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.</dd>
<dt>( <em>test_condition</em> )</dt>
<dd>true if <em>test_condition</em> is true</dd>
<dt>! <em>test_condition</em></dt>
<dd>true if <em>test_condition</em> is false</dd>
<dt><em>test_condition1</em> &amp;&amp;
<em>test_condition2</em></dt>
<dd>true if both <em>test_condition1</em> and
<em>test_condition2</em> are true</dd>
<dt><em>test_condition1</em> || <em>test_condition2</em></dt>
<dd>true if either <em>test_condition1</em> or
<em>test_condition2</em> is true</dd>
</dl>
<p>"<em>=</em>" and "<em>!=</em>" bind more tightly than
"<em>&amp;&amp;</em>" and "<em>||</em>". "<em>!</em>" binds
most tightly. Thus, the following are equivalent:</p>
<pre>
&lt;!--#if expr="$a = test1 &amp;&amp; $b = test2" --&gt;
&lt;!--#if expr="($a = test1) &amp;&amp; ($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,</p>
<pre>
<em>string1 string2</em> results in <em>string1 string2</em>
<em>'string1 string2'</em> results in <em>string1 string2</em>
</pre>
<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.
<hr />
<h2><a id="xbithack" name="xbithack">XBitHack</a>
directive</h2>
<!--%plaintext &lt;?INDEX {\tt XBitHack} directive&gt; -->
<a href="directive-dict.html#Syntax"
rel="Help"><strong>Syntax:</strong></a> XBitHack
on|off|full<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>. XBitHack can take on
the following values:</p>
<dl>
<dt>off</dt>
<dd>No special treatment of executable files.</dd>
<dt>on</dt>
<dd>Any file that has the user-execute bit set will be
treated as a server-parsed html document.</dd>
<dt>full</dt>
<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).</p>
</dd>
</dl>
<p><!--#include virtual="footer.html" -->
</p>
</body>
</html>