home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / apache_2.2.8-win32-x86-no_ssl.msi / Data1.cab / _7A1519049996399EB7E99869B3407208 < prev    next >
Extensible Markup Language  |  2007-12-05  |  45KB  |  855 lines

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
  4.         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  5.               This file is generated from xml source: DO NOT EDIT
  6.         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  7.       -->
  8. <title>mod_include - Apache HTTP Server</title>
  9. <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
  10. <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
  11. <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
  12. <link href="../images/favicon.ico" rel="shortcut icon" /></head>
  13. <body>
  14. <div id="page-header">
  15. <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
  16. <p class="apache">Apache HTTP Server Version 2.2</p>
  17. <img alt="" src="../images/feather.gif" /></div>
  18. <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
  19. <div id="path">
  20. <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Modules</a></div>
  21. <div id="page-content">
  22. <div id="preamble"><h1>Apache Module mod_include</h1>
  23. <div class="toplang">
  24. <p><span>Available Languages: </span><a href="../en/mod/mod_include.html" title="English"> en </a> |
  25. <a href="../ja/mod/mod_include.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
  26. </div>
  27. <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Server-parsed html documents (Server Side Includes)</td></tr>
  28. <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
  29. <tr><th><a href="module-dict.html#ModuleIdentifier">ModuleáIdentifier:</a></th><td>include_module</td></tr>
  30. <tr><th><a href="module-dict.html#SourceFile">SourceáFile:</a></th><td>mod_include.c</td></tr>
  31. <tr><th><a href="module-dict.html#Compatibility">Compatibility:</a></th><td>Implemented as an output filter since Apache
  32. 2.0</td></tr></table>
  33. <h3>Summary</h3>
  34.  
  35.     <p>This module provides a filter which will process files
  36.     before they are sent to the client. The processing is
  37.     controlled by specially formatted SGML comments, referred to as
  38.     <dfn>elements</dfn>. These elements allow conditional text, the
  39.     inclusion of other files or programs, as well as the setting and
  40.     printing of environment variables.</p>
  41. </div>
  42. <div id="quickview"><h3 class="directives">Directives</h3>
  43. <ul id="toc">
  44. <li><img alt="" src="../images/down.gif" /> <a href="#ssienableaccess">SSIEnableAccess</a></li>
  45. <li><img alt="" src="../images/down.gif" /> <a href="#ssiendtag">SSIEndTag</a></li>
  46. <li><img alt="" src="../images/down.gif" /> <a href="#ssierrormsg">SSIErrorMsg</a></li>
  47. <li><img alt="" src="../images/down.gif" /> <a href="#ssistarttag">SSIStartTag</a></li>
  48. <li><img alt="" src="../images/down.gif" /> <a href="#ssitimeformat">SSITimeFormat</a></li>
  49. <li><img alt="" src="../images/down.gif" /> <a href="#ssiundefinedecho">SSIUndefinedEcho</a></li>
  50. <li><img alt="" src="../images/down.gif" /> <a href="#xbithack">XBitHack</a></li>
  51. </ul>
  52. <h3>Topics</h3>
  53. <ul id="topics">
  54. <li><img alt="" src="../images/down.gif" /> <a href="#enabling">Enabling Server-Side Includes</a></li>
  55. <li><img alt="" src="../images/down.gif" /> <a href="#pathinfo">PATH_INFO with Server Side Includes</a></li>
  56. <li><img alt="" src="../images/down.gif" /> <a href="#elements">Basic Elements</a></li>
  57. <li><img alt="" src="../images/down.gif" /> <a href="#includevars">Include Variables</a></li>
  58. <li><img alt="" src="../images/down.gif" /> <a href="#substitution">Variable Substitution</a></li>
  59. <li><img alt="" src="../images/down.gif" /> <a href="#flowctrl">Flow Control Elements</a></li>
  60. </ul><h3>See also</h3>
  61. <ul class="seealso">
  62. <li><code class="directive"><a href="../mod/core.html#options">Options</a></code></li>
  63. <li><code class="directive"><a href="../mod/core.html#acceptpathinfo">AcceptPathInfo</a></code></li>
  64. <li><a href="../filter.html">Filters</a></li>
  65. <li><a href="../howto/ssi.html">SSI Tutorial</a></li>
  66. </ul></div>
  67. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  68. <div class="section">
  69. <h2><a name="enabling" id="enabling">Enabling Server-Side Includes</a></h2>
  70.     
  71.  
  72.     <p>Server Side Includes are implemented by the
  73.     <code>INCLUDES</code> <a href="../filter.html">filter</a>. If
  74.     documents containing server-side include directives are given
  75.     the extension .shtml, the following directives will make Apache
  76.     parse them and assign the resulting document the mime type of
  77.     <code>text/html</code>:</p>
  78.  
  79.     <div class="example"><p><code>
  80.       AddType text/html .shtml<br />
  81.       AddOutputFilter INCLUDES .shtml
  82.     </code></p></div>
  83.  
  84.     <p>The following directive must be given for the directories
  85.     containing the shtml files (typically in a
  86.     <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> section,
  87.     but this directive is also valid in <code>.htaccess</code> files if
  88.     <code class="directive"><a href="../mod/core.html#allowoverride">AllowOverride</a></code> <code>Options</code>
  89.     is set):</p>
  90.  
  91.     <div class="example"><p><code>
  92.       Options +Includes
  93.     </code></p></div>
  94.  
  95.     <p>For backwards compatibility, the <code>server-parsed</code>
  96.     <a href="../handler.html">handler</a> also activates the
  97.     INCLUDES filter. As well, Apache will activate the INCLUDES
  98.     filter for any document with mime type
  99.     <code>text/x-server-parsed-html</code> or
  100.     <code>text/x-server-parsed-html3</code> (and the resulting
  101.     output will have the mime type <code>text/html</code>).</p>
  102.  
  103.     <p>For more information, see our <a href="../howto/ssi.html">Tutorial on Server Side Includes</a>.</p>
  104. </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  105. <div class="section">
  106. <h2><a name="pathinfo" id="pathinfo">PATH_INFO with Server Side Includes</a></h2>
  107.     
  108.  
  109.     <p>Files processed for server-side includes no longer accept
  110.     requests with <code>PATH_INFO</code> (trailing pathname information)
  111.     by default.  You can use the <code class="directive"><a href="../mod/core.html#acceptpathinfo">AcceptPathInfo</a></code> directive to
  112.     configure the server to accept requests with <code>PATH_INFO</code>.</p>
  113. </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  114. <div class="section">
  115. <h2><a name="elements" id="elements">Basic Elements</a></h2>
  116.     <p>The document is parsed as an HTML document, with special
  117.     commands embedded as SGML comments. A command has the syntax: </p>
  118.  
  119.     <div class="example"><p><code>
  120.       <!--#<var>element</var> <var>attribute</var>=<var>value</var>
  121.       <var>attribute</var>=<var>value</var> ... -->
  122.     </code></p></div>
  123.  
  124.     <p>The value will often be enclosed in double quotes, but single
  125.     quotes (<code>'</code>) and backticks (<code>`</code>) are also
  126.     possible. Many commands only allow a single attribute-value pair.
  127.     Note that the comment terminator (<code>--></code>) should be
  128.     preceded by whitespace to ensure that it isn't considered part of
  129.     an SSI token. Note that the leading <code><!--#</code> is <em>one</em>
  130.     token and may not contain any whitespaces.</p>
  131.  
  132.     <p>The allowed elements are listed in the following table:</p>
  133.  
  134.     <table class="bordered">
  135.     <tr><th>Element</th><th>Description</th></tr>
  136.     <tr><td><code><a href="#element.config">config</a></code></td>
  137.         <td>configure output formats</td></tr>
  138.     <tr><td><code><a href="#element.echo">echo</a></code></td>
  139.         <td>print variables</td></tr>
  140.     <tr><td><code><a href="#element.exec">exec</a></code></td>
  141.         <td>execute external programs</td></tr>
  142.     <tr><td><code><a href="#element.fsize">fsize</a></code></td>
  143.         <td>print size of a file</td></tr>
  144.     <tr><td><code><a href="#element.flastmod">flastmod</a></code></td>
  145.         <td>print last modification time of a file</td></tr>
  146.     <tr><td><code><a href="#element.include">include</a></code></td>
  147.         <td>include a file</td></tr>
  148.     <tr><td><code><a href="#element.printenv">printenv</a></code></td>
  149.         <td>print all available variables</td></tr>
  150.     <tr><td><code><a href="#element.set">set</a></code></td>
  151.         <td>set a value of a variable</td></tr>
  152.     </table>
  153.  
  154.     <p>SSI elements may be defined by modules other than
  155.     <code class="module"><a href="../mod/mod_include.html">mod_include</a></code>. In fact, the <code><a href="#element.exec">exec</a></code> element is provided by
  156.     <code class="module"><a href="../mod/mod_cgi.html">mod_cgi</a></code>, and will only be available if this
  157.     module is loaded.</p>
  158.  
  159.     <h3><a name="element.config" id="element.config">The config Element</a></h3>
  160.       <p>This command controls various aspects of the parsing. The
  161.       valid attributes are:</p>
  162.  
  163.       <dl>
  164.       <dt><code>echomsg</code> (<em>Apache 2.1 and later</em>)</dt>
  165.       <dd>The value is a message that is sent back to the
  166.       client if the <code><a href="#element.echo">echo</a></code> element
  167.       attempts to echo an undefined variable. This overrides any <code class="directive"><a href="#ssiundefinedecho">SSIUndefinedEcho</a></code> directives.</dd>
  168.  
  169.       <dt><code>errmsg</code></dt>
  170.       <dd>The value is a message that is sent back to the
  171.       client if an error occurs while parsing the
  172.       document. This overrides any <code class="directive"><a href="#ssierrormsg">SSIErrorMsg</a></code> directives.</dd>
  173.  
  174.       <dt><code>sizefmt</code></dt>
  175.       <dd>The value sets the format to be used which displaying
  176.       the size of a file. Valid values are <code>bytes</code>
  177.       for a count in bytes, or <code>abbrev</code> for a count
  178.       in Kb or Mb as appropriate, for example a size of 1024 bytes
  179.       will be printed as "1K".</dd>
  180.  
  181.       <dt><code>timefmt</code></dt>
  182.       <dd>The value is a string to be used by the
  183.       <code>strftime(3)</code> library routine when printing
  184.       dates.</dd>
  185.       </dl>
  186.      
  187.  
  188.     <h3><a name="element.echo" id="element.echo">The echo Element</a></h3>
  189.       <p>This command prints one of the <a href="#includevars">include
  190.       variables</a>, defined below. If the variable is unset, the result is
  191.       determined by the <code class="directive"><a href="#ssiundefinedecho">SSIUndefinedEcho</a></code> directive. Any dates printed are
  192.       subject to the currently configured <code>timefmt</code>.</p>
  193.  
  194.       <p>Attributes:</p> 
  195.  
  196.       <dl>
  197.       <dt><code>var</code></dt>
  198.       <dd>The value is the name of the variable to print.</dd>
  199.  
  200.       <dt><code>encoding</code></dt>
  201.       <dd><p>Specifies how Apache should encode special characters
  202.       contained in the variable before outputting them. If set
  203.       to <code>none</code>, no encoding will be done. If set to
  204.       <code>url</code>, then URL encoding (also known as %-encoding;
  205.       this is appropriate for use within URLs in links, etc.) will be
  206.       performed. At the start of an <code>echo</code> element,
  207.       the default is set to <code>entity</code>, resulting in entity
  208.       encoding (which is appropriate in the context of a block-level
  209.       HTML element, <em>e.g.</em> a paragraph of text). This can be
  210.       changed by adding an <code>encoding</code> attribute, which will
  211.       remain in effect until the next <code>encoding</code> attribute
  212.       is encountered or the element ends, whichever comes first.</p>
  213.  
  214.       <p>The <code>encoding</code> attribute must <em>precede</em> the
  215.       corresponding <code>var</code> attribute to be effective, and 
  216.       only special characters as defined in the ISO-8859-1 character
  217.       encoding will be encoded. This encoding process may not have the
  218.       desired result if a different character encoding is in use.</p>
  219.  
  220.       <div class="warning">
  221.         In order to avoid cross-site scripting issues, you should
  222.         <em>always</em> encode user supplied data.
  223.       </div>
  224.       </dd>
  225.       </dl>
  226.      
  227.  
  228.     <h3><a name="element.exec" id="element.exec">The exec Element</a></h3>
  229.       <p>The <code>exec</code> command executes a given shell command or
  230.       CGI script. It requires <code class="module"><a href="../mod/mod_cgi.html">mod_cgi</a></code> to be present
  231.       in the server. If <code class="directive"><a href="../mod/core.html#options">Options</a></code>
  232.       <code>IncludesNOEXEC</code> is set, this command is completely
  233.       disabled. The valid attributes are:</p>
  234.  
  235.       <dl>
  236.       <dt><code>cgi</code></dt>
  237.       <dd><p>The value specifies a (%-encoded) URL-path to
  238.       the CGI script. If the path does not begin with a slash (/),
  239.       then it is taken to be relative to the current
  240.       document. The document referenced by this path is
  241.       invoked as a CGI script, even if the server would not
  242.       normally recognize it as such. However, the directory
  243.       containing the script must be enabled for CGI scripts
  244.       (with <code class="directive"><a href="../mod/mod_alias.html#scriptalias">ScriptAlias</a></code>
  245.       or <code class="directive"><a href="../mod/core.html#options">Options</a></code>
  246.       <code>ExecCGI</code>).</p>
  247.  
  248.       <p>The CGI script is given the <code>PATH_INFO</code> and query
  249.       string (<code>QUERY_STRING</code>) of the original request from the
  250.       client; these <em>cannot</em> be specified in the URL path. The
  251.       include variables will be available to the script in addition to
  252.       the standard <a href="mod_cgi.html">CGI</a> environment.</p>
  253.  
  254.       <div class="example"><h3>Example</h3><p><code>
  255.         <!--#exec cgi="/cgi-bin/example.cgi" -->
  256.       </code></p></div>
  257.  
  258.       <p>If the script returns a <code>Location:</code> header instead of
  259.       output, then this will be translated into an HTML anchor.</p>
  260.  
  261.       <p>The <code><a href="#includevirtual">include virtual</a></code>
  262.       element should be used in preference to <code>exec cgi</code>. In
  263.       particular, if you need to pass additional arguments to a CGI program,
  264.       using the query string, this cannot be done with <code>exec
  265.       cgi</code>, but can be done with <code>include virtual</code>, as
  266.       shown here:</p>
  267.  
  268.       <div class="example"><p><code>
  269.         <!--#include virtual="/cgi-bin/example.cgi?argument=value" -->
  270.       </code></p></div>
  271.       </dd>
  272.  
  273.       <dt><code>cmd</code></dt>
  274.       <dd><p>The server will execute the given string using
  275.       <code>/bin/sh</code>. The <a href="#includevars">include variables</a> are available to the command, in addition
  276.       to the usual set of CGI variables.</p>
  277.  
  278.       <p>The use of <code><a href="#includevirtual">#include virtual</a></code> is almost always prefered to using
  279.       either <code>#exec cgi</code> or <code>#exec cmd</code>. The former
  280.       (<code>#include virtual</code>) uses the standard Apache sub-request
  281.       mechanism to include files or scripts. It is much better tested and
  282.       maintained.</p>
  283.  
  284.       <p>In addition, on some platforms, like Win32, and on unix when
  285.       using <a href="../suexec.html">suexec</a>, you cannot pass arguments
  286.       to a command in an <code>exec</code> directive, or otherwise include
  287.       spaces in the command. Thus, while the following will work under a
  288.       non-suexec configuration on unix, it will not produce the desired
  289.       result under Win32, or when running suexec:</p>
  290.  
  291.       <div class="example"><p><code>
  292.         <!--#exec cmd="perl /path/to/perlscript arg1 arg2" -->
  293.       </code></p></div>
  294.       </dd>
  295.       </dl>
  296.      
  297.  
  298.     <h3><a name="element.fsize" id="element.fsize">The fsize Element</a></h3>
  299.       <p>This command prints the size of the specified file, subject
  300.       to the <code>sizefmt</code> format specification. Attributes:</p>
  301.  
  302.       <dl>
  303.       <dt><code>file</code></dt>
  304.       <dd>The value is a path relative to the directory
  305.       containing the current document being parsed.</dd>
  306.  
  307.       <dt><code>virtual</code></dt>
  308.       <dd>The value is a (%-encoded) URL-path. If it does not begin with
  309.       a slash (/) then it is taken to be relative to the current document.
  310.       Note, that this does <em>not</em> print the size of any CGI output,
  311.       but the size of the CGI script itself.</dd>
  312.       </dl>
  313.      
  314.  
  315.     <h3><a name="element.flastmod" id="element.flastmod">The flastmod Element</a></h3>
  316.       <p>This command prints the last modification date of the
  317.       specified file, subject to the <code>timefmt</code> format
  318.       specification. The attributes are the same as for the
  319.       <code><a href="#element.fsize">fsize</a></code> command.</p>
  320.      
  321.  
  322.     <h3><a name="element.include" id="element.include">The include Element</a></h3>
  323.       <p>This command inserts the text of another document or file
  324.       into the parsed file. Any included file is subject to the usual
  325.       access control. If the directory containing the parsed file has
  326.       <a href="core.html#options">Options</a>
  327.       <code>IncludesNOEXEC</code> set, then only documents with a text
  328.       <a class="glossarylink" href="../glossary.html#mime-type" title="see glossary">MIME-type</a> (<code>text/plain</code>,
  329.       <code>text/html</code> etc.) will be included. Otherwise CGI
  330.       scripts are invoked as normal using the complete URL given in
  331.       the command, including any query string.</p>
  332.  
  333.       <p>An attribute defines the location of the document; the
  334.       inclusion is done for each attribute given to the include
  335.       command. The valid attributes are:</p>
  336.  
  337.       <dl>
  338.       <dt><code>file</code></dt>
  339.       <dd>The value is a path relative to the directory
  340.       containing the current document being parsed. It cannot
  341.       contain <code>../</code>, nor can it be an absolute path.
  342.       Therefore, you cannot include files that are outside of the
  343.       document root, or above the current document in the directory
  344.       structure. The <code>virtual</code> attribute should always be
  345.       used in preference to this one.</dd>
  346.  
  347.       <dt><code><a id="includevirtual" name="includevirtual">virtual</a></code></dt>
  348.       <dd><p>The value is a (%-encoded) URL-path. The URL cannot contain a
  349.       scheme or hostname, only a path and an optional query string. If it
  350.       does not begin with a slash (/) then it is taken to be relative to the
  351.       current document.</p>
  352.  
  353.       <p>A URL is constructed from the attribute, and the output the
  354.       server would return if the URL were accessed by the client is
  355.       included in the parsed output. Thus included files can be nested.</p>
  356.  
  357.       <p>If the specified URL is a CGI program, the program will be
  358.       executed and its output inserted in place of the directive in the
  359.       parsed file. You may include a query string in a CGI url:</p>
  360.      
  361.       <div class="example"><p><code>
  362.         <!--#include virtual="/cgi-bin/example.cgi?argument=value" -->
  363.       </code></p></div>
  364.            
  365.       <p><code>include virtual</code> should be used in preference
  366.       to <code>exec cgi</code> to include the output of CGI programs
  367.       into an HTML document.</p>
  368.       </dd>
  369.       </dl>
  370.      
  371.  
  372.     <h3><a name="element.printenv" id="element.printenv">The printenv Element</a></h3>
  373.       <p>This prints out a listing of all existing variables and
  374.       their values. Special characters are entity encoded (see the <code><a href="#element.echo">echo</a></code> element for details)
  375.       before being output. There are no attributes.</p>
  376.  
  377.       <div class="example"><h3>Example</h3><p><code>
  378.         <!--#printenv -->
  379.       </code></p></div>
  380.      
  381.  
  382.     <h3><a name="element.set" id="element.set">The set Element</a></h3>
  383.       <p>This sets the value of a variable. Attributes:</p>
  384.  
  385.       <dl>
  386.       <dt><code>var</code></dt>
  387.       <dd>The name of the variable to set.</dd>
  388.  
  389.       <dt><code>value</code></dt>
  390.       <dd>The value to give a variable.</dd>
  391.       </dl>
  392.  
  393.       <div class="example"><h3>Example</h3><p><code>
  394.         <!--#set var="category" value="help" -->
  395.       </code></p></div>
  396.      
  397. </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  398. <div class="section">
  399. <h2><a name="includevars" id="includevars">Include Variables</a></h2>
  400.     
  401.  
  402.     <p>In addition to the variables in the standard CGI environment,
  403.     these are available for the <code>echo</code> command, for
  404.     <code>if</code> and <code>elif</code>, and to any program
  405.     invoked by the document.</p>
  406.  
  407.     <dl>
  408.       <dt><code>DATE_GMT</code></dt>
  409.       <dd>The current date in Greenwich Mean Time.</dd>
  410.  
  411.       <dt><code>DATE_LOCAL</code></dt>
  412.       <dd>The current date in the local time zone.</dd>
  413.  
  414.       <dt><code>DOCUMENT_NAME</code></dt>
  415.       <dd>The filename (excluding directories) of the document
  416.       requested by the user.</dd>
  417.  
  418.       <dt><code>DOCUMENT_URI</code></dt>
  419.       <dd>The (%-decoded) URL path of the document requested by the
  420.       user. Note that in the case of nested include files, this is
  421.       <em>not</em> the URL for the current document.</dd>
  422.  
  423.       <dt><code>LAST_MODIFIED</code></dt>
  424.       <dd>The last modification date of the document requested by
  425.       the user.</dd>
  426.  
  427.       <dt><code>QUERY_STRING_UNESCAPED</code></dt>
  428.       <dd>If a query string is present, this variable contains the
  429.       (%-decoded) query string, which is <em>escaped</em> for shell
  430.       usage (special characters like <code>&</code> etc. are
  431.       preceded by backslashes).</dd>
  432.     </dl>
  433. </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  434. <div class="section">
  435. <h2><a name="substitution" id="substitution">Variable Substitution</a></h2>
  436.  
  437.     <p>Variable substitution is done within quoted strings in most
  438.     cases where they may reasonably occur as an argument to an SSI
  439.     directive. This includes the <code>config</code>,
  440.     <code>exec</code>, <code>flastmod</code>, <code>fsize</code>,
  441.     <code>include</code>, <code>echo</code>, and <code>set</code>
  442.     directives, as well as the arguments to conditional operators.
  443.     You can insert a literal dollar sign into the string using backslash
  444.     quoting:</p>
  445.  
  446.     <div class="example"><p><code>
  447.       <!--#if expr="$a = \$test" -->
  448.     </code></p></div>
  449.  
  450.     <p>If a variable reference needs to be substituted in the
  451.     middle of a character sequence that might otherwise be
  452.     considered a valid identifier in its own right, it can be
  453.     disambiguated by enclosing the reference in braces,
  454.     <em>a la</em> shell substitution:</p>
  455.  
  456.     <div class="example"><p><code>
  457.       <!--#set var="Zed" value="${REMOTE_HOST}_${REQUEST_METHOD}" -->
  458.     </code></p></div>
  459.  
  460.     <p>This will result in the <code>Zed</code> variable being set
  461.     to "<code>X_Y</code>" if <code>REMOTE_HOST</code> is
  462.     "<code>X</code>" and <code>REQUEST_METHOD</code> is
  463.     "<code>Y</code>".</p>
  464.  
  465.     <p>The below example will print "in foo" if the
  466.     <code>DOCUMENT_URI</code> is <code>/foo/file.html</code>, "in bar"
  467.     if it is <code>/bar/file.html</code> and "in neither" otherwise:</p>
  468.  
  469.     <div class="example"><p><code>
  470.       <!--#if expr='"$DOCUMENT_URI" = "/foo/file.html"' --><br />
  471.       <span class="indent">
  472.         in foo<br />
  473.       </span>
  474.       <!--#elif expr='"$DOCUMENT_URI" = "/bar/file.html"' --><br />
  475.       <span class="indent">
  476.         in bar<br />
  477.       </span>
  478.       <!--#else --><br />
  479.       <span class="indent">
  480.         in neither<br />
  481.       </span>
  482.       <!--#endif -->
  483.     </code></p></div>
  484. </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  485. <div class="section">
  486. <h2><a name="flowctrl" id="flowctrl">Flow Control Elements</a></h2>
  487.     
  488.  
  489.     <p>The basic flow control elements are:</p>
  490.  
  491.     <div class="example"><p><code>
  492.       <!--#if expr="<var>test_condition</var>" --><br />
  493.       <!--#elif expr="<var>test_condition</var>" --><br />
  494.       <!--#else --><br />
  495.       <!--#endif -->
  496.     </code></p></div>
  497.  
  498.     <p>The <code>if</code> element works like an if statement in a
  499.     programming language. The test condition is evaluated and if
  500.     the result is true, then the text until the next <code>elif</code>,
  501.     <code>else</code> or <code>endif</code> element is included in the
  502.     output stream.</p>
  503.  
  504.     <p>The <code>elif</code> or <code>else</code> statements are be used
  505.     to put text into the output stream if the original
  506.     <var>test_condition</var> was false. These elements are optional.</p>
  507.  
  508.     <p>The <code>endif</code> element ends the <code>if</code> element
  509.     and is required.</p>
  510.  
  511.     <p><var>test_condition</var> is one of the following:</p>
  512.  
  513.     <dl>
  514.       <dt><code><var>string</var></code></dt>
  515.       <dd>true if <var>string</var> is not empty</dd>
  516.  
  517.       <dt><code><var>-A string</var></code></dt>
  518.       <dd><p>true if the URL represented by the string is accessible by
  519.       configuration, false otherwise. This test only has an effect if
  520.       <code class="directive">SSIEnableAccess</code> is on. This is useful
  521.       where content on a page is to be hidden from users who are not
  522.       authorized to view the URL, such as a link to that URL. Note
  523.       that the URL is only tested for whether access would be granted,
  524.       not whether the URL exists.</p>
  525.  
  526.       <div class="example"><h3>Example</h3><p><code>
  527.         <!--#if expr="-A /private" --><br />
  528.         <span class="indent">
  529.           Click <a href="/private">here</a> to access private
  530.           information.<br />
  531.         </span>
  532.         <!--#endif -->
  533.       </code></p></div>
  534.       </dd>
  535.  
  536.       <dt><code><var>string1</var> = <var>string2</var><br />
  537.       <var>string1</var> == <var>string2</var><br />
  538.       <var>string1</var> != <var>string2</var></code></dt>
  539.       
  540.       <dd><p>Compare <var>string1</var> with <var>string2</var>. If
  541.       <var>string2</var> has the form <code>/<var>string2</var>/</code>
  542.       then it is treated as a regular expression. Regular expressions are
  543.       implemented by the <a href="http://www.pcre.org">PCRE</a> engine and
  544.       have the same syntax as those in <a href="http://www.perl.com">perl
  545.       5</a>. Note that <code>==</code> is just an alias for <code>=</code>
  546.       and behaves exactly the same way.</p>
  547.  
  548.       <p>If you are matching positive (<code>=</code> or <code>==</code>), you
  549.       can capture grouped parts of the regular expression. The captured parts
  550.       are stored in the special variables <code>$1</code> ..
  551.       <code>$9</code>.</p>
  552.  
  553.       <div class="example"><h3>Example</h3><p><code>
  554.         <!--#if expr="$QUERY_STRING = /^sid=([a-zA-Z0-9]+)/" --><br />
  555.         <span class="indent">
  556.           <!--#set var="session" value="$1" --><br />
  557.         </span>
  558.         <!--#endif -->
  559.       </code></p></div>
  560.       </dd>
  561.  
  562.       <dt><code><var>string1</var> < <var>string2</var><br />
  563.        <var>string1</var> <= <var>string2</var><br />
  564.        <var>string1</var> > <var>string2</var><br />
  565.        <var>string1</var> >= <var>string2</var></code></dt>
  566.  
  567.       <dd>Compare <var>string1</var> with <var>string2</var>. Note, that
  568.       strings are compared <em>literally</em> (using
  569.       <code>strcmp(3)</code>). Therefore the string "100" is less than
  570.       "20".</dd>
  571.  
  572.       <dt><code>( <var>test_condition</var> )</code></dt>
  573.       <dd>true if <var>test_condition</var> is true</dd>
  574.  
  575.       <dt><code>! <var>test_condition</var></code></dt>
  576.       <dd>true if <var>test_condition</var> is false</dd>
  577.  
  578.       <dt><code><var>test_condition1</var> &&
  579.         <var>test_condition2</var></code></dt>
  580.       <dd>true if both <var>test_condition1</var> and
  581.       <var>test_condition2</var> are true</dd>
  582.  
  583.       <dt><code><var>test_condition1</var> ||
  584.         <var>test_condition2</var></code></dt>
  585.       <dd>true if either <var>test_condition1</var> or
  586.       <var>test_condition2</var> is true</dd>
  587.     </dl>
  588.  
  589.     <p>"<code>=</code>" and "<code>!=</code>" bind more tightly than
  590.     "<code>&&</code>" and "<code>||</code>". "<code>!</code>" binds
  591.     most tightly. Thus, the following are equivalent:</p>
  592.  
  593.     <div class="example"><p><code>
  594.       <!--#if expr="$a = test1 && $b = test2" --><br />
  595.       <!--#if expr="($a = test1) && ($b = test2)" -->
  596.     </code></p></div>
  597.  
  598.     <p>The boolean operators <code>&&</code> and <code>||</code>
  599.     share the same priority. So if you want to bind such an operator more
  600.     tightly, you should use parentheses.</p>
  601.  
  602.     <p>Anything that's not recognized as a variable or an operator
  603.     is treated as a string. Strings can also be quoted:
  604.     <code>'string'</code>. Unquoted strings can't contain whitespace
  605.     (blanks and tabs) because it is used to separate tokens such as
  606.     variables. If multiple strings are found in a row, they are
  607.     concatenated using blanks. So,</p>
  608.  
  609.     <div class="example"><p><code><var>string1</var>    <var>string2</var></code> results in <code><var>string1</var> <var>string2</var></code><br />
  610.       <br />
  611.       and<br />
  612.       <br />
  613.       <code>'<var>string1</var>    <var>string2</var>'</code> results in <code><var>string1</var>    <var>string2</var></code>.</p></div>
  614.  
  615.     <div class="note"><h3>Optimization of Boolean Expressions</h3>
  616.       <p>If the expressions become more complex and slow down processing
  617.       significantly, you can try to optimize them according to the
  618.       evaluation rules:</p>
  619.       <ul>
  620.       <li>Expressions are evaluated from left to right</li>
  621.       <li>Binary boolean operators (<code>&&</code> and <code>||</code>)
  622.           are short circuited wherever possible. In conclusion with the rule
  623.           above that means, <code class="module"><a href="../mod/mod_include.html">mod_include</a></code> evaluates at first
  624.           the left expression. If the left result is sufficient to determine
  625.           the end result, processing stops here. Otherwise it evaluates the
  626.           right side and computes the end result from both left and right
  627.           results.</li>
  628.       <li>Short circuit evaluation is turned off as long as there are regular
  629.           expressions to deal with. These must be evaluated to fill in the
  630.           backreference variables (<code>$1</code> .. <code>$9</code>).</li>
  631.       </ul>
  632.       <p>If you want to look how a particular expression is handled, you can
  633.       recompile <code class="module"><a href="../mod/mod_include.html">mod_include</a></code> using the
  634.       <code>-DDEBUG_INCLUDE</code> compiler option. This inserts for every
  635.       parsed expression tokenizer information, the parse tree and how it is
  636.       evaluated into the output sent to the client.</p>
  637.     </div>
  638. </div>
  639. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  640. <div class="directive-section"><h2><a name="SSIEnableAccess" id="SSIEnableAccess">SSIEnableAccess</a> <a name="ssienableaccess" id="ssienableaccess">Directive</a></h2>
  641. <table class="directive">
  642. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enable the -A flag during conditional flow control processing.</td></tr>
  643. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>SSIEnableAccess on|off</code></td></tr>
  644. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>SSIEnableAccess off</code></td></tr>
  645. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>directory, .htaccess</td></tr>
  646. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  647. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  648. </table>
  649.     <p>The <code class="directive">SSIEnableAccess</code> directive controls whether
  650.     the -A test is enabled during conditional flow control processing.
  651.     <code class="directive">SSIEnableAccess</code> can take on the following values:</p>
  652.  
  653.     <dl>
  654.  
  655.       <dt><code>off</code></dt>
  656.       <dd><!--#if expr="-A /foo"--> will be interpreted as a series
  657.       of string and regular expression tokens, the -A has no special
  658.       meaning.</dd>
  659.  
  660.       <dt><code>on</code></dt>
  661.       <dd><!--#if expr="-A /foo"--> will evaluate to false if the
  662.       URL /foo is inaccessible by configuration, or true otherwise.</dd>
  663.  
  664.     </dl>
  665.  
  666.  
  667. </div>
  668. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  669. <div class="directive-section"><h2><a name="SSIEndTag" id="SSIEndTag">SSIEndTag</a> <a name="ssiendtag" id="ssiendtag">Directive</a></h2>
  670. <table class="directive">
  671. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>String that ends an include element</td></tr>
  672. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>SSIEndTag <var>tag</var></code></td></tr>
  673. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>SSIEndTag "-->"</code></td></tr>
  674. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
  675. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  676. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  677. <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.30 and later.</td></tr>
  678. </table>
  679.     <p>This directive changes the string that <code class="module"><a href="../mod/mod_include.html">mod_include</a></code>
  680.     looks for to mark the end of an include element.</p>
  681.  
  682.     <div class="example"><h3>Example</h3><p><code>
  683.       SSIEndTag "%>"
  684.     </code></p></div>
  685.  
  686.  
  687. <h3>See also</h3>
  688. <ul>
  689. <li><code class="directive"><a href="#ssistarttag">SSIStartTag</a></code></li>
  690. </ul>
  691. </div>
  692. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  693. <div class="directive-section"><h2><a name="SSIErrorMsg" id="SSIErrorMsg">SSIErrorMsg</a> <a name="ssierrormsg" id="ssierrormsg">Directive</a></h2>
  694. <table class="directive">
  695. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Error message displayed when there is an SSI
  696. error</td></tr>
  697. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>SSIErrorMsg <var>message</var></code></td></tr>
  698. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>SSIErrorMsg "[an error occurred while processing this
  699. directive]"</code></td></tr>
  700. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  701. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
  702. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  703. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  704. <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.30 and later.</td></tr>
  705. </table>
  706.     <p>The <code class="directive">SSIErrorMsg</code> directive changes the error
  707.     message displayed when <code class="module"><a href="../mod/mod_include.html">mod_include</a></code> encounters an
  708.     error. For production servers you may consider changing the default
  709.     error message to <code>"<!-- Error -->"</code> so that
  710.     the message is not presented to the user.</p>
  711.  
  712.     <p>This directive has the same effect as the <code><!--#config
  713.     errmsg=<var>message</var> --></code> element.</p>
  714.  
  715.     <div class="example"><h3>Example</h3><p><code>
  716.       SSIErrorMsg "<!-- Error -->"
  717.     </code></p></div>
  718.  
  719. </div>
  720. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  721. <div class="directive-section"><h2><a name="SSIStartTag" id="SSIStartTag">SSIStartTag</a> <a name="ssistarttag" id="ssistarttag">Directive</a></h2>
  722. <table class="directive">
  723. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>String that starts an include element</td></tr>
  724. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>SSIStartTag <var>tag</var></code></td></tr>
  725. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>SSIStartTag "<!--#"</code></td></tr>
  726. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
  727. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  728. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  729. <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.30 and later.</td></tr>
  730. </table>
  731.     <p>This directive changes the string that <code class="module"><a href="../mod/mod_include.html">mod_include</a></code>
  732.     looks for to mark an include element to process.</p>
  733.  
  734.     <p>You may want to use this option if you have 2 servers parsing the
  735.     output of a file each processing different commands (possibly at
  736.     different times).</p> 
  737.  
  738.     <div class="example"><h3>Example</h3><p><code>
  739.       SSIStartTag "<%"<br />
  740.       SSIEndTag   "%>"
  741.     </code></p></div>
  742.  
  743.     <p>The example given above, which also specifies a matching
  744.     <code class="directive"><a href="#ssiendtag">SSIEndTag</a></code>, will 
  745.     allow you to use SSI directives as shown in the example 
  746.     below:</p>
  747.  
  748.     <div class="example"><h3>SSI directives with alternate start and end tags</h3><p><code>
  749.       <%printenv %>
  750.     </code></p></div>
  751.  
  752. <h3>See also</h3>
  753. <ul>
  754. <li><code class="directive"><a href="#ssiendtag">SSIEndTag</a></code></li>
  755. </ul>
  756. </div>
  757. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  758. <div class="directive-section"><h2><a name="SSITimeFormat" id="SSITimeFormat">SSITimeFormat</a> <a name="ssitimeformat" id="ssitimeformat">Directive</a></h2>
  759. <table class="directive">
  760. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Configures the format in which date strings are
  761. displayed</td></tr>
  762. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>SSITimeFormat <var>formatstring</var></code></td></tr>
  763. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>SSITimeFormat "%A, %d-%b-%Y %H:%M:%S %Z"</code></td></tr>
  764. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  765. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
  766. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  767. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  768. <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.30 and later.</td></tr>
  769. </table>
  770. <p>This directive changes the format in which date strings are displayed 
  771.     when echoing <code>DATE</code> environment variables. The
  772.     <var>formatstring</var> is as in <code>strftime(3)</code> from the
  773.     C standard library.</p>
  774.  
  775.     <p>This directive has the same effect as the <code><!--#config
  776.     timefmt=<var>formatstring</var> --></code> element.</p>
  777.  
  778.     <div class="example"><h3>Example</h3><p><code>
  779.       SSITimeFormat "%R, %B %d, %Y"
  780.     </code></p></div>
  781.  
  782.     <p>The above directive would cause times to be displayed in the
  783.     format "22:26, June 14, 2002".</p>
  784.  
  785. </div>
  786. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  787. <div class="directive-section"><h2><a name="SSIUndefinedEcho" id="SSIUndefinedEcho">SSIUndefinedEcho</a> <a name="ssiundefinedecho" id="ssiundefinedecho">Directive</a></h2>
  788. <table class="directive">
  789. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>String displayed when an unset variable is echoed</td></tr>
  790. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>SSIUndefinedEcho <var>string</var></code></td></tr>
  791. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>SSIUndefinedEcho "(none)"</code></td></tr>
  792. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  793. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>All</td></tr>
  794. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  795. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  796. <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in version 2.0.34 and later.</td></tr>
  797. </table>
  798.     <p>This directive changes the string that <code class="module"><a href="../mod/mod_include.html">mod_include</a></code>
  799.     displays when a variable is not set and "echoed".</p>
  800.  
  801.     <div class="example"><h3>Example</h3><p><code>
  802.       SSIUndefinedEcho "<!-- undef -->"
  803.     </code></p></div>
  804.  
  805. </div>
  806. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  807. <div class="directive-section"><h2><a name="XBitHack" id="XBitHack">XBitHack</a> <a name="xbithack" id="xbithack">Directive</a></h2>
  808. <table class="directive">
  809. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Parse SSI directives in files with the execute bit
  810. set</td></tr>
  811. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>XBitHack on|off|full</code></td></tr>
  812. <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>XBitHack off</code></td></tr>
  813. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  814. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>Options</td></tr>
  815. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  816. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_include</td></tr>
  817. </table>
  818.     <p>The <code class="directive">XBitHack</code> directive controls the parsing
  819.     of ordinary html documents. This directive only affects files associated
  820.     with the <a class="glossarylink" href="../glossary.html#mime-type" title="see glossary">MIME-type</a> <code>text/html</code>. <code class="directive">XBitHack</code> can take on the following values:</p>
  821.  
  822.     <dl>
  823.       <dt><code>off</code></dt>
  824.       <dd>No special treatment of executable files.</dd>
  825.  
  826.       <dt><code>on</code></dt>
  827.       <dd>Any <code>text/html</code> file that has the user-execute bit
  828.       set will be treated as a server-parsed html document.</dd>
  829.  
  830.       <dt><code>full</code></dt>
  831.       <dd>As for <code>on</code> but also test the group-execute bit.
  832.       If it is set, then set the <code>Last-modified</code> date of the
  833.       returned file to be the last modified time of the file. If
  834.       it is not set, then no last-modified date is sent. Setting
  835.       this bit allows clients and proxies to cache the result of
  836.       the request. 
  837.  
  838.       <div class="note"><h3>Note</h3>
  839.       <p>You would not want to use the full option, unless you assure the
  840.       group-execute bit is unset for every SSI script which might <code>#include</code> a CGI or otherwise produces different output on
  841.       each hit (or could potentially change on subsequent requests).</p>
  842.       </div>
  843.       </dd>
  844.     </dl>
  845.  
  846.  
  847. </div>
  848. </div>
  849. <div class="bottomlang">
  850. <p><span>Available Languages: </span><a href="../en/mod/mod_include.html" title="English"> en </a> |
  851. <a href="../ja/mod/mod_include.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a></p>
  852. </div><div id="footer">
  853. <p class="apache">Copyright 2007 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
  854. <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
  855. </body></html>