dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<?xml version="1.0" encoding="ISO-8859-1"?>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd<!--
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen This file is generated from xml source: DO NOT EDIT
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5a58787efeb02a1c3f06569d019ad81fd2efa06end -->
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc<title>Apache httpd Tutorial: Introduction to Server Side Includes - Apache HTTP Server Version 2.5</title>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" />
2e545ce2450a9953665f701bb05350f0d3f26275nd<script src="/style/scripts/prettify.min.js" type="text/javascript">
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen</script>
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/images/favicon.ico" rel="shortcut icon" /></head>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<body id="manual-page"><div id="page-header">
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p>
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<p class="apache">Apache HTTP Server Version 2.5</p>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<img alt="" src="/images/feather.gif" /></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="/images/left.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div id="path">
ab0204844dcf70616de77d7deef9feb30c634072rbowen<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a> &gt; <a href="./">How-To / Tutorials</a></div><div id="page-content"><div id="preamble"><h1>Apache httpd Tutorial: Introduction to Server Side Includes</h1>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<div class="toplang">
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<p><span>Available Languages: </span><a href="/en/howto/ssi.html" title="English">&nbsp;en&nbsp;</a> |
e8df3f2d5908b6903c510c8e839a5db27d1e104bgryzor<a href="/fr/howto/ssi.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a> |
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd<a href="/ja/howto/ssi.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung<a href="/ko/howto/ssi.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd</div>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<p>Server-side includes provide a means to add dynamic content to
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowenexisting HTML documents.</p>
5a58787efeb02a1c3f06569d019ad81fd2efa06end</div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#related">Introduction</a></li>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<li><img alt="" src="/images/down.gif" /> <a href="#what">What are SSI?</a></li>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<li><img alt="" src="/images/down.gif" /> <a href="#configuring">Configuring your server to permit SSI</a></li>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<li><img alt="" src="/images/down.gif" /> <a href="#basic">Basic SSI directives</a></li>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<li><img alt="" src="/images/down.gif" /> <a href="#additionalexamples">Additional examples</a></li>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<li><img alt="" src="/images/down.gif" /> <a href="#config">What else can I config?</a></li>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<li><img alt="" src="/images/down.gif" /> <a href="#exec">Executing commands</a></li>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<li><img alt="" src="/images/down.gif" /> <a href="#advanced">Advanced SSI techniques</a></li>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<li><img alt="" src="/images/down.gif" /> <a href="#conclusion">Conclusion</a></li>
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="section">
5a58787efeb02a1c3f06569d019ad81fd2efa06end<h2><a name="related" id="related">Introduction</a></h2>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="/mod/mod_include.html">mod_include</a></code></li><li><code class="module"><a href="/mod/mod_cgi.html">mod_cgi</a></code></li><li><code class="module"><a href="/mod/mod_expires.html">mod_expires</a></code></li></ul></td><td><ul><li><code class="directive"><a href="/mod/core.html#options">Options</a></code></li><li><code class="directive"><a href="/mod/mod_include.html#xbithack">XBitHack</a></code></li><li><code class="directive"><a href="/mod/mod_mime.html#addtype">AddType</a></code></li><li><code class="directive"><a href="/mod/core.html#setoutputfilter">SetOutputFilter</a></code></li><li><code class="directive"><a href="/mod/mod_setenvif.html#browsermatchnocase">BrowserMatchNoCase</a></code></li></ul></td></tr></table>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>This article deals with Server Side Includes, usually called
838d5ac1582d50020a146d747b64d64548fa8c92rbowen simply SSI. In this article, I'll talk about configuring your
838d5ac1582d50020a146d747b64d64548fa8c92rbowen server to permit SSI, and introduce some basic SSI techniques
838d5ac1582d50020a146d747b64d64548fa8c92rbowen for adding dynamic content to your existing HTML pages.</p>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>In the latter part of the article, we'll talk about some of
838d5ac1582d50020a146d747b64d64548fa8c92rbowen the somewhat more advanced things that can be done with SSI,
838d5ac1582d50020a146d747b64d64548fa8c92rbowen such as conditional statements in your SSI directives.</p>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
5a58787efeb02a1c3f06569d019ad81fd2efa06end</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="section">
5a58787efeb02a1c3f06569d019ad81fd2efa06end<h2><a name="what" id="what">What are SSI?</a></h2>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>SSI (Server Side Includes) are directives that are placed in
838d5ac1582d50020a146d747b64d64548fa8c92rbowen HTML pages, and evaluated on the server while the pages are
838d5ac1582d50020a146d747b64d64548fa8c92rbowen being served. They let you add dynamically generated content to
838d5ac1582d50020a146d747b64d64548fa8c92rbowen an existing HTML page, without having to serve the entire page
838d5ac1582d50020a146d747b64d64548fa8c92rbowen via a CGI program, or other dynamic technology.</p>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen <p>For example, you might place a directive into an existing HTML
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen page, such as:</p>
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen
a55271a69085520100823b73bd2060fb123bbfb0humbedooh <div class="example"><p><code>
a55271a69085520100823b73bd2060fb123bbfb0humbedooh &lt;!--#echo var="DATE_LOCAL" --&gt;
a55271a69085520100823b73bd2060fb123bbfb0humbedooh </code></p></div>
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen <p>And, when the page is served, this fragment will be evaluated and replaced with its value:</p>
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen <div class="example"><p><code>
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen Tuesday, 15-Jan-2013 19:28:54 EST
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen </code></p></div>
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>The decision of when to use SSI, and when to have your page
838d5ac1582d50020a146d747b64d64548fa8c92rbowen entirely generated by some program, is usually a matter of how
838d5ac1582d50020a146d747b64d64548fa8c92rbowen much of the page is static, and how much needs to be
838d5ac1582d50020a146d747b64d64548fa8c92rbowen recalculated every time the page is served. SSI is a great way
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen to add small pieces of information, such as the current time - shown
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen above. But if a majority of your page is being generated at the time
4e6fe58e85c14d942c1644747e145b1d901ba342rbowen that it is served, you need to look for some other solution.</p>
5a58787efeb02a1c3f06569d019ad81fd2efa06end</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="section">
5a58787efeb02a1c3f06569d019ad81fd2efa06end<h2><a name="configuring" id="configuring">Configuring your server to permit SSI</a></h2>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>To permit SSI on your server, you must have the following
838d5ac1582d50020a146d747b64d64548fa8c92rbowen directive either in your <code>httpd.conf</code> file, or in a
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>.htaccess</code> file:</p>
20f499565e77defe9dab24dd85c02f38a1175855nd<pre class="prettyprint lang-config">Options +Includes</pre>
267a7c2766f092ea7e8aa919548c03403fabccfbhumbedooh
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>This tells Apache that you want to permit files to be parsed
53934620d9523ce77c2346ef14b5ba22106c5b26slive for SSI directives. Note that most configurations contain
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen multiple <code class="directive"><a href="/mod/core.html#options">Options</a></code> directives
53934620d9523ce77c2346ef14b5ba22106c5b26slive that can override each other. You will probably need to apply the
53934620d9523ce77c2346ef14b5ba22106c5b26slive <code>Options</code> to the specific directory where you want SSI
53934620d9523ce77c2346ef14b5ba22106c5b26slive enabled in order to assure that it gets evaluated last.</p>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Not just any file is parsed for SSI directives. You have to
838d5ac1582d50020a146d747b64d64548fa8c92rbowen tell Apache which files should be parsed. There are two ways to
838d5ac1582d50020a146d747b64d64548fa8c92rbowen do this. You can tell Apache to parse any file with a
838d5ac1582d50020a146d747b64d64548fa8c92rbowen particular file extension, such as <code>.shtml</code>, with
838d5ac1582d50020a146d747b64d64548fa8c92rbowen the following directives:</p>
e9425c93ba098a7844e138a61e1be5f46d2aa2ddnd<pre class="prettyprint lang-config"> AddType text/html .shtml<br />
4aa603e6448b99f9371397d439795c91a93637eand AddOutputFilter INCLUDES .shtml</pre>
419d55842022e9e257941bfe226549661fb2c6c7humbedooh
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>One disadvantage to this approach is that if you wanted to
838d5ac1582d50020a146d747b64d64548fa8c92rbowen add SSI directives to an existing page, you would have to
838d5ac1582d50020a146d747b64d64548fa8c92rbowen change the name of that page, and all links to that page, in
838d5ac1582d50020a146d747b64d64548fa8c92rbowen order to give it a <code>.shtml</code> extension, so that those
838d5ac1582d50020a146d747b64d64548fa8c92rbowen directives would be executed.</p>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
33f5e027b85636ab978d3f8e2c74b07e260f60b4erikabele <p>The other method is to use the <code class="directive"><a href="/mod/mod_include.html#xbithack">XBitHack</a></code> directive:</p>
20f499565e77defe9dab24dd85c02f38a1175855nd<pre class="prettyprint lang-config">XBitHack on</pre>
419d55842022e9e257941bfe226549661fb2c6c7humbedooh
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
33f5e027b85636ab978d3f8e2c74b07e260f60b4erikabele <p><code class="directive"><a href="/mod/mod_include.html#xbithack">XBitHack</a></code>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen tells Apache to parse files for SSI
838d5ac1582d50020a146d747b64d64548fa8c92rbowen directives if they have the execute bit set. So, to add SSI
838d5ac1582d50020a146d747b64d64548fa8c92rbowen directives to an existing page, rather than having to change
838d5ac1582d50020a146d747b64d64548fa8c92rbowen the file name, you would just need to make the file executable
838d5ac1582d50020a146d747b64d64548fa8c92rbowen using <code>chmod</code>.</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen chmod +x pagename.html
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>A brief comment about what not to do. You'll occasionally
838d5ac1582d50020a146d747b64d64548fa8c92rbowen see people recommending that you just tell Apache to parse all
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>.html</code> files for SSI, so that you don't have to
838d5ac1582d50020a146d747b64d64548fa8c92rbowen mess with <code>.shtml</code> file names. These folks have
33f5e027b85636ab978d3f8e2c74b07e260f60b4erikabele perhaps not heard about <code class="directive"><a href="/mod/mod_include.html#xbithack">XBitHack</a></code>. The thing to
838d5ac1582d50020a146d747b64d64548fa8c92rbowen keep in mind is that, by doing this, you're requiring that
838d5ac1582d50020a146d747b64d64548fa8c92rbowen Apache read through every single file that it sends out to
838d5ac1582d50020a146d747b64d64548fa8c92rbowen clients, even if they don't contain any SSI directives. This
838d5ac1582d50020a146d747b64d64548fa8c92rbowen can slow things down quite a bit, and is not a good idea.</p>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Of course, on Windows, there is no such thing as an execute
838d5ac1582d50020a146d747b64d64548fa8c92rbowen bit to set, so that limits your options a little.</p>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>In its default configuration, Apache does not send the last
838d5ac1582d50020a146d747b64d64548fa8c92rbowen modified date or content length HTTP headers on SSI pages,
838d5ac1582d50020a146d747b64d64548fa8c92rbowen because these values are difficult to calculate for dynamic
838d5ac1582d50020a146d747b64d64548fa8c92rbowen content. This can prevent your document from being cached, and
838d5ac1582d50020a146d747b64d64548fa8c92rbowen result in slower perceived client performance. There are two
838d5ac1582d50020a146d747b64d64548fa8c92rbowen ways to solve this:</p>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <ol>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <li>Use the <code>XBitHack Full</code> configuration. This
838d5ac1582d50020a146d747b64d64548fa8c92rbowen tells Apache to determine the last modified date by looking
838d5ac1582d50020a146d747b64d64548fa8c92rbowen only at the date of the originally requested file, ignoring
838d5ac1582d50020a146d747b64d64548fa8c92rbowen the modification date of any included files.</li>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf <li>Use the directives provided by
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen <code class="module"><a href="/mod/mod_expires.html">mod_expires</a></code> to set an explicit expiration
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen time on your files, thereby letting browsers and proxies
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen know that it is acceptable to cache them.</li>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen </ol>
5a58787efeb02a1c3f06569d019ad81fd2efa06end</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="section">
5a58787efeb02a1c3f06569d019ad81fd2efa06end<h2><a name="basic" id="basic">Basic SSI directives</a></h2>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>SSI directives have the following syntax:</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
160f60077e5a018a1f27f756e76f80d7bbc3f070rbowen &lt;!--#function attribute=value attribute=value ... --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>It is formatted like an HTML comment, so if you don't have
838d5ac1582d50020a146d747b64d64548fa8c92rbowen SSI correctly enabled, the browser will ignore it, but it will
838d5ac1582d50020a146d747b64d64548fa8c92rbowen still be visible in the HTML source. If you have SSI correctly
838d5ac1582d50020a146d747b64d64548fa8c92rbowen configured, the directive will be replaced with its
838d5ac1582d50020a146d747b64d64548fa8c92rbowen results.</p>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
160f60077e5a018a1f27f756e76f80d7bbc3f070rbowen <p>The function can be one of a number of things, and we'll talk
838d5ac1582d50020a146d747b64d64548fa8c92rbowen some more about most of these in the next installment of this
838d5ac1582d50020a146d747b64d64548fa8c92rbowen series. For now, here are some examples of what you can do with
838d5ac1582d50020a146d747b64d64548fa8c92rbowen SSI</p>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<h3><a name="todaysdate" id="todaysdate">Today's date</a></h3>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
5996a8bd615ff844dd85872452570ae6d1bdb064slive &lt;!--#echo var="DATE_LOCAL" --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
160f60077e5a018a1f27f756e76f80d7bbc3f070rbowen <p>The <code>echo</code> function just spits out the value of a
838d5ac1582d50020a146d747b64d64548fa8c92rbowen variable. There are a number of standard variables, which
838d5ac1582d50020a146d747b64d64548fa8c92rbowen include the whole set of environment variables that are
838d5ac1582d50020a146d747b64d64548fa8c92rbowen available to CGI programs. Also, you can define your own
160f60077e5a018a1f27f756e76f80d7bbc3f070rbowen variables with the <code>set</code> function.</p>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>If you don't like the format in which the date gets printed,
160f60077e5a018a1f27f756e76f80d7bbc3f070rbowen you can use the <code>config</code> function, with a
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>timefmt</code> attribute, to modify that formatting.</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen &lt;!--#config timefmt="%A %B %d, %Y" --&gt;<br />
5996a8bd615ff844dd85872452570ae6d1bdb064slive Today is &lt;!--#echo var="DATE_LOCAL" --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<h3><a name="lastmodified" id="lastmodified">Modification date of the file</a></h3>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen This document last modified &lt;!--#flastmod file="index.html" --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
160f60077e5a018a1f27f756e76f80d7bbc3f070rbowen <p>This function is also subject to <code>timefmt</code> format
838d5ac1582d50020a146d747b64d64548fa8c92rbowen configurations.</p>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<h3><a name="cgi" id="cgi">Including the results of a CGI program</a></h3>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>This is one of the more common uses of SSI - to output the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen results of a CGI program, such as everybody's favorite, a ``hit
838d5ac1582d50020a146d747b64d64548fa8c92rbowen counter.''</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen &lt;!--#include virtual="/cgi-bin/counter.pl" --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
5a58787efeb02a1c3f06569d019ad81fd2efa06end</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="section">
5a58787efeb02a1c3f06569d019ad81fd2efa06end<h2><a name="additionalexamples" id="additionalexamples">Additional examples</a></h2>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Following are some specific examples of things you can do in
838d5ac1582d50020a146d747b64d64548fa8c92rbowen your HTML documents with SSI.</p>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<h3><a name="docmodified" id="docmodified">When was this document
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowenmodified?</a></h3>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Earlier, we mentioned that you could use SSI to inform the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen user when the document was most recently modified. However, the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen actual method for doing that was left somewhat in question. The
838d5ac1582d50020a146d747b64d64548fa8c92rbowen following code, placed in your HTML document, will put such a
838d5ac1582d50020a146d747b64d64548fa8c92rbowen time stamp on your page. Of course, you will have to have SSI
838d5ac1582d50020a146d747b64d64548fa8c92rbowen correctly enabled, as discussed above.</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen &lt;!--#config timefmt="%A %B %d, %Y" --&gt;<br />
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen This file last modified &lt;!--#flastmod file="ssi.shtml" --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Of course, you will need to replace the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>ssi.shtml</code> with the actual name of the file that
838d5ac1582d50020a146d747b64d64548fa8c92rbowen you're referring to. This can be inconvenient if you're just
838d5ac1582d50020a146d747b64d64548fa8c92rbowen looking for a generic piece of code that you can paste into any
838d5ac1582d50020a146d747b64d64548fa8c92rbowen file, so you probably want to use the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>LAST_MODIFIED</code> variable instead:</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen &lt;!--#config timefmt="%D" --&gt;<br />
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen This file last modified &lt;!--#echo var="LAST_MODIFIED" --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>For more details on the <code>timefmt</code> format, go to
7058ea0c9aabcc4e3a7cb2baa076645715c452d0slive your favorite search site and look for <code>strftime</code>. The
838d5ac1582d50020a146d747b64d64548fa8c92rbowen syntax is the same.</p>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
93a89127fafc9d64767c71d81f667bf5e31c2cfdnd<h3><a name="standard-footer" id="standard-footer">Including a standard footer</a></h3>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>If you are managing any site that is more than a few pages,
838d5ac1582d50020a146d747b64d64548fa8c92rbowen you may find that making changes to all those pages can be a
838d5ac1582d50020a146d747b64d64548fa8c92rbowen real pain, particularly if you are trying to maintain some kind
838d5ac1582d50020a146d747b64d64548fa8c92rbowen of standard look across all those pages.</p>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Using an include file for a header and/or a footer can
838d5ac1582d50020a146d747b64d64548fa8c92rbowen reduce the burden of these updates. You just have to make one
838d5ac1582d50020a146d747b64d64548fa8c92rbowen footer file, and then include it into each page with the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>include</code> SSI command. The <code>include</code>
160f60077e5a018a1f27f756e76f80d7bbc3f070rbowen function can determine what file to include with either the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>file</code> attribute, or the <code>virtual</code>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen attribute. The <code>file</code> attribute is a file path,
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <em>relative to the current directory</em>. That means that it
838d5ac1582d50020a146d747b64d64548fa8c92rbowen cannot be an absolute file path (starting with /), nor can it
838d5ac1582d50020a146d747b64d64548fa8c92rbowen contain ../ as part of that path. The <code>virtual</code>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen attribute is probably more useful, and should specify a URL
838d5ac1582d50020a146d747b64d64548fa8c92rbowen relative to the document being served. It can start with a /,
838d5ac1582d50020a146d747b64d64548fa8c92rbowen but must be on the same server as the file being served.</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen &lt;!--#include virtual="/footer.html" --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>I'll frequently combine the last two things, putting a
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>LAST_MODIFIED</code> directive inside a footer file to be
838d5ac1582d50020a146d747b64d64548fa8c92rbowen included. SSI directives can be contained in the included file,
838d5ac1582d50020a146d747b64d64548fa8c92rbowen and includes can be nested - that is, the included file can
838d5ac1582d50020a146d747b64d64548fa8c92rbowen include another file, and so on.</p>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
5a58787efeb02a1c3f06569d019ad81fd2efa06end</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="section">
5a58787efeb02a1c3f06569d019ad81fd2efa06end<h2><a name="config" id="config">What else can I config?</a></h2>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>In addition to being able to <code>config</code> the time
838d5ac1582d50020a146d747b64d64548fa8c92rbowen format, you can also <code>config</code> two other things.</p>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Usually, when something goes wrong with your SSI directive,
838d5ac1582d50020a146d747b64d64548fa8c92rbowen you get the message</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen [an error occurred while processing this directive]
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>If you want to change that message to something else, you
838d5ac1582d50020a146d747b64d64548fa8c92rbowen can do so with the <code>errmsg</code> attribute to the
160f60077e5a018a1f27f756e76f80d7bbc3f070rbowen <code>config</code> function:</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen &lt;!--#config errmsg="[It appears that you don't know how to use SSI]" --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Hopefully, end users will never see this message, because
838d5ac1582d50020a146d747b64d64548fa8c92rbowen you will have resolved all the problems with your SSI
838d5ac1582d50020a146d747b64d64548fa8c92rbowen directives before your site goes live. (Right?)</p>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>And you can <code>config</code> the format in which file
838d5ac1582d50020a146d747b64d64548fa8c92rbowen sizes are returned with the <code>sizefmt</code> attribute. You
838d5ac1582d50020a146d747b64d64548fa8c92rbowen can specify <code>bytes</code> for a full count in bytes, or
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>abbrev</code> for an abbreviated number in Kb or Mb, as
838d5ac1582d50020a146d747b64d64548fa8c92rbowen appropriate.</p>
5a58787efeb02a1c3f06569d019ad81fd2efa06end </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="section">
5a58787efeb02a1c3f06569d019ad81fd2efa06end<h2><a name="exec" id="exec">Executing commands</a></h2>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>I expect that I'll have an article some time in the coming
838d5ac1582d50020a146d747b64d64548fa8c92rbowen months about using SSI with small CGI programs. For now, here's
838d5ac1582d50020a146d747b64d64548fa8c92rbowen something else that you can do with the <code>exec</code>
160f60077e5a018a1f27f756e76f80d7bbc3f070rbowen function. You can actually have SSI execute a command using the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen shell (<code>/bin/sh</code>, to be precise - or the DOS shell,
838d5ac1582d50020a146d747b64d64548fa8c92rbowen if you're on Win32). The following, for example, will give you
838d5ac1582d50020a146d747b64d64548fa8c92rbowen a directory listing.</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen &lt;pre&gt;<br />
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen &lt;!--#exec cmd="ls" --&gt;<br />
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen &lt;/pre&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>or, on Windows</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen &lt;pre&gt;<br />
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen &lt;!--#exec cmd="dir" --&gt;<br />
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen &lt;/pre&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>You might notice some strange formatting with this directive
838d5ac1582d50020a146d747b64d64548fa8c92rbowen on Windows, because the output from <code>dir</code> contains
838d5ac1582d50020a146d747b64d64548fa8c92rbowen the string ``&lt;<code>dir</code>&gt;'' in it, which confuses
838d5ac1582d50020a146d747b64d64548fa8c92rbowen browsers.</p>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Note that this feature is exceedingly dangerous, as it will
838d5ac1582d50020a146d747b64d64548fa8c92rbowen execute whatever code happens to be embedded in the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>exec</code> tag. If you have any situation where users
838d5ac1582d50020a146d747b64d64548fa8c92rbowen can edit content on your web pages, such as with a
838d5ac1582d50020a146d747b64d64548fa8c92rbowen ``guestbook'', for example, make sure that you have this
838d5ac1582d50020a146d747b64d64548fa8c92rbowen feature disabled. You can allow SSI, but not the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>exec</code> feature, with the <code>IncludesNOEXEC</code>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen argument to the <code>Options</code> directive.</p>
5a58787efeb02a1c3f06569d019ad81fd2efa06end </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="section">
5a58787efeb02a1c3f06569d019ad81fd2efa06end<h2><a name="advanced" id="advanced">Advanced SSI techniques</a></h2>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>In addition to spitting out content, Apache SSI gives you
838d5ac1582d50020a146d747b64d64548fa8c92rbowen the option of setting variables, and using those variables in
838d5ac1582d50020a146d747b64d64548fa8c92rbowen comparisons and conditionals.</p>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<h3><a name="variables" id="variables">Setting variables</a></h3>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Using the <code>set</code> directive, you can set variables
838d5ac1582d50020a146d747b64d64548fa8c92rbowen for later use. We'll need this later in the discussion, so
838d5ac1582d50020a146d747b64d64548fa8c92rbowen we'll talk about it here. The syntax of this is as follows:</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen &lt;!--#set var="name" value="Rich" --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
a3c2c9d7f7f8b1ca10d108398b64ace6fc57c711slive <p>In addition to merely setting values literally like that, you
a3c2c9d7f7f8b1ca10d108398b64ace6fc57c711slive can use any other variable, including <a href="/env.html">environment variables</a> or the variables
a3c2c9d7f7f8b1ca10d108398b64ace6fc57c711slive discussed above (like <code>LAST_MODIFIED</code>, for example) to
a3c2c9d7f7f8b1ca10d108398b64ace6fc57c711slive give values to your variables. You will specify that something is
a3c2c9d7f7f8b1ca10d108398b64ace6fc57c711slive a variable, rather than a literal string, by using the dollar sign
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf ($) before the name of the variable.</p>
a3c2c9d7f7f8b1ca10d108398b64ace6fc57c711slive
a3c2c9d7f7f8b1ca10d108398b64ace6fc57c711slive <div class="example"><p><code> &lt;!--#set var="modified" value="$LAST_MODIFIED" --&gt;
a3c2c9d7f7f8b1ca10d108398b64ace6fc57c711slive </code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>To put a literal dollar sign into the value of your
838d5ac1582d50020a146d747b64d64548fa8c92rbowen variable, you need to escape the dollar sign with a
838d5ac1582d50020a146d747b64d64548fa8c92rbowen backslash.</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen &lt;!--#set var="cost" value="\$100" --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Finally, if you want to put a variable in the midst of a
838d5ac1582d50020a146d747b64d64548fa8c92rbowen longer string, and there's a chance that the name of the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen variable will run up against some other characters, and thus be
838d5ac1582d50020a146d747b64d64548fa8c92rbowen confused with those characters, you can place the name of the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen variable in braces, to remove this confusion. (It's hard to
838d5ac1582d50020a146d747b64d64548fa8c92rbowen come up with a really good example of this, but hopefully
838d5ac1582d50020a146d747b64d64548fa8c92rbowen you'll get the point.)</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen &lt;!--#set var="date" value="${DATE_LOCAL}_${DATE_GMT}" --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<h3><a name="conditional" id="conditional">Conditional expressions</a></h3>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Now that we have variables, and are able to set and compare
838d5ac1582d50020a146d747b64d64548fa8c92rbowen their values, we can use them to express conditionals. This
838d5ac1582d50020a146d747b64d64548fa8c92rbowen lets SSI be a tiny programming language of sorts.
db110d4edeb95018cff2232d9a9cd7a505739dc5erikabele <code class="module"><a href="/mod/mod_include.html">mod_include</a></code> provides an <code>if</code>,
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>elif</code>, <code>else</code>, <code>endif</code>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen structure for building conditional statements. This allows you
838d5ac1582d50020a146d747b64d64548fa8c92rbowen to effectively generate multiple logical pages out of one
838d5ac1582d50020a146d747b64d64548fa8c92rbowen actual page.</p>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>The structure of this conditional construct is:</p>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen<div class="example"><p><code>
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen &lt;!--#if expr="test_condition" --&gt;<br />
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen &lt;!--#elif expr="test_condition" --&gt;<br />
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen &lt;!--#else --&gt;<br />
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen &lt;!--#endif --&gt;
dc643bc37eec0af989b9623deaa81fb9499b6c8erbowen</code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>A <em>test_condition</em> can be any sort of logical
838d5ac1582d50020a146d747b64d64548fa8c92rbowen comparison - either comparing values to one another, or testing
838d5ac1582d50020a146d747b64d64548fa8c92rbowen the ``truth'' of a particular value. (A given string is true if
838d5ac1582d50020a146d747b64d64548fa8c92rbowen it is nonempty.) For a full list of the comparison operators
db110d4edeb95018cff2232d9a9cd7a505739dc5erikabele available to you, see the <code class="module"><a href="/mod/mod_include.html">mod_include</a></code>
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen documentation.</p>
a99c5d4cc3cab6a62b04d52000dbc22ce1fa2d94coar
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen <p>For example, if you wish to customize the text on your web page
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen based on the time of day, you could use the following recipe, placed
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen in the HTML page:</p>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen <div class="example"><p><code>
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen Good
948e3a11e34f0434c50491dc89ede8f1ebadb20bjailletc &lt;!--#if expr="%{TIME_HOUR} &lt;12" --&gt;<br />
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen morning!<br />
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen &lt;!--#else --&gt;<br />
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen afternoon!<br />
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen &lt;!--#endif --&gt;<br />
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen </code></p></div>
ef4ce729f5fd58437a4c41d1166b9e9013db6c5frbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>Any other variable (either ones that you define, or normal
838d5ac1582d50020a146d747b64d64548fa8c92rbowen environment variables) can be used in conditional statements.
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen See <a href="/expr.html">Expressions in Apache HTTP Server</a> for
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen more information on the expression evaluation engine.</p>
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen <p>With Apache's ability to set environment variables with the
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <code>SetEnvIf</code> directives, and other related directives,
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen this functionality can let you do a wide variety of dynamic content
ef11aba17c2ae6364e2f1329b24d205acf6dc4e4rbowen on the server side without resorting a full web application.</p>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
5a58787efeb02a1c3f06569d019ad81fd2efa06end</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="section">
5a58787efeb02a1c3f06569d019ad81fd2efa06end<h2><a name="conclusion" id="conclusion">Conclusion</a></h2>
838d5ac1582d50020a146d747b64d64548fa8c92rbowen
838d5ac1582d50020a146d747b64d64548fa8c92rbowen <p>SSI is certainly not a replacement for CGI, or other
838d5ac1582d50020a146d747b64d64548fa8c92rbowen technologies used for generating dynamic web pages. But it is a
838d5ac1582d50020a146d747b64d64548fa8c92rbowen great way to add small amounts of dynamic content to pages,
838d5ac1582d50020a146d747b64d64548fa8c92rbowen without doing a lot of extra work.</p>
5a58787efeb02a1c3f06569d019ad81fd2efa06end</div></div>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<div class="bottomlang">
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<p><span>Available Languages: </span><a href="/en/howto/ssi.html" title="English">&nbsp;en&nbsp;</a> |
e8df3f2d5908b6903c510c8e839a5db27d1e104bgryzor<a href="/fr/howto/ssi.html" hreflang="fr" rel="alternate" title="Fran�ais">&nbsp;fr&nbsp;</a> |
7f5b59ccc63c0c0e3e678a168f09ee6a2f51f9d0nd<a href="/ja/howto/ssi.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung<a href="/ko/howto/ssi.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p>
ed62c84ee0911cfebbd8da319ac00757b555707chumbedooh</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
0d0ba3a410038e179b695446bb149cce6264e0abnd<script type="text/javascript"><!--//--><![CDATA[//><!--
ed62c84ee0911cfebbd8da319ac00757b555707chumbedoohvar comments_shortname = 'httpd';
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedoohvar comments_identifier = 'http://httpd.apache.org/docs/trunk/howto/ssi.html';
0d0ba3a410038e179b695446bb149cce6264e0abnd(function(w, d) {
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
ed62c84ee0911cfebbd8da319ac00757b555707chumbedooh d.write('<div id="comments_thread"><\/div>');
0d0ba3a410038e179b695446bb149cce6264e0abnd var s = d.createElement('script');
0d0ba3a410038e179b695446bb149cce6264e0abnd s.type = 'text/javascript';
0d0ba3a410038e179b695446bb149cce6264e0abnd s.async = true;
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedooh s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
0d0ba3a410038e179b695446bb149cce6264e0abnd (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
0d0ba3a410038e179b695446bb149cce6264e0abnd }
0d0ba3a410038e179b695446bb149cce6264e0abnd else {
ed62c84ee0911cfebbd8da319ac00757b555707chumbedooh d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
0d0ba3a410038e179b695446bb149cce6264e0abnd }
0d0ba3a410038e179b695446bb149cce6264e0abnd})(window, document);
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh//--><!]]></script></div><div id="footer">
205f749042ed530040a4f0080dbcb47ceae8a374rjung<p class="apache">Copyright 2015 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>
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
0d0ba3a410038e179b695446bb149cce6264e0abndif (typeof(prettyPrint) !== 'undefined') {
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd prettyPrint();
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd}
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd//--><!]]></script>
5a58787efeb02a1c3f06569d019ad81fd2efa06end</body></html>