ssi.html.en revision e8df3f2d5908b6903c510c8e839a5db27d1e104b
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd This file is generated from xml source: DO NOT EDIT
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<title>Apache Tutorial: Introduction to Server Side Includes - Apache HTTP Server</title>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<link href="/images/favicon.ico" rel="shortcut icon" /></head>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<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>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<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.3</a> > <a href="./">How-To / Tutorials</a></div><div id="page-content"><div id="preamble"><h1>Apache Tutorial: Introduction to Server Side Includes</h1>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<p><span>Available Languages: </span><a href="/en/howto/ssi.html" title="English"> en </a> |
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<a href="/fr/howto/ssi.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a> |
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<a href="/ja/howto/ssi.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<a href="/ko/howto/ssi.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<p>Server-side includes provide a means to add dynamic content to
1cc20a8827ff6056399d64e3106b44d31e8e0e53ndexisting HTML documents.</p>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#related">Introduction</a></li>
6abfd7bce937fd1dd27d29321a25b6056d9cb20dnd<li><img alt="" src="/images/down.gif" /> <a href="#what">What are SSI?</a></li>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<li><img alt="" src="/images/down.gif" /> <a href="#configuring">Configuring your server to permit SSI</a></li>
35b1112eadc3479a2d81ea1b836aa87f21505ee9jerenkrantz<li><img alt="" src="/images/down.gif" /> <a href="#basic">Basic SSI directives</a></li>
35b1112eadc3479a2d81ea1b836aa87f21505ee9jerenkrantz<li><img alt="" src="/images/down.gif" /> <a href="#additionalexamples">Additional examples</a></li>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<li><img alt="" src="/images/down.gif" /> <a href="#config">What else can I config?</a></li>
a12dd6260a66f51e25119982390def72e2db4be5nd<li><img alt="" src="/images/down.gif" /> <a href="#exec">Executing commands</a></li>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<li><img alt="" src="/images/down.gif" /> <a href="#advanced">Advanced SSI techniques</a></li>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<li><img alt="" src="/images/down.gif" /> <a href="#conclusion">Conclusion</a></li>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd <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>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd <p>This article deals with Server Side Includes, usually called
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd simply SSI. In this article, I'll talk about configuring your
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd server to permit SSI, and introduce some basic SSI techniques
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd for adding dynamic content to your existing HTML pages.</p>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd <p>In the latter part of the article, we'll talk about some of
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd the somewhat more advanced things that can be done with SSI,
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd such as conditional statements in your SSI directives.</p>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd <p>SSI (Server Side Includes) are directives that are placed in
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd HTML pages, and evaluated on the server while the pages are
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd being served. They let you add dynamically generated content to
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd an existing HTML page, without having to serve the entire page
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd via a CGI program, or other dynamic technology.</p>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd <p>The decision of when to use SSI, and when to have your page
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd entirely generated by some program, is usually a matter of how
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd much of the page is static, and how much needs to be
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd recalculated every time the page is served. SSI is a great way
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd to add small pieces of information, such as the current time.
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd But if a majority of your page is being generated at the time
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd that it is served, you need to look for some other
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd solution.</p>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd<h2><a name="configuring" id="configuring">Configuring your server to permit SSI</a></h2>
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd <p>To permit SSI on your server, you must have the following
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd directive either in your <code>httpd.conf</code> file, or in a
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd Options +Includes
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd <p>This tells Apache that you want to permit files to be parsed
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd for SSI directives. Note that most configurations contain
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd multiple <code class="directive"><a href="/mod/core.html#options">Options</a></code> directives
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd that can override each other. You will probably need to apply the
29fb68cf24dbdb4985cbb4734cb6074ea4bbab26nd <code>Options</code> to the specific directory where you want SSI
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd enabled in order to assure that it gets evaluated last.</p>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd <p>Not just any file is parsed for SSI directives. You have to
b05ab3ff5ab54aa22610b13d56eaba6ddfc3db60nd tell Apache which files should be parsed. There are two ways to
43e2c3ca329ff3ca8cb7613d455ddb3794edf7adnd do this. You can tell Apache to parse any file with a
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd particular file extension, such as <code>.shtml</code>, with
1cc20a8827ff6056399d64e3106b44d31e8e0e53nd the following directives:</p>
b95ae799514ad86a15610ad75808d7065e9847c9kess AddOutputFilter INCLUDES .shtml
<p>The other method is to use the <code class="directive"><a href="/mod/mod_include.html#xbithack">XBitHack</a></code> directive:</p>
chmod +x pagename.html
perhaps not heard about <code class="directive"><a href="/mod/mod_include.html#xbithack">XBitHack</a></code>. The thing to
<code class="module"><a href="/mod/mod_expires.html">mod_expires</a></code> to set an explicit expiration
This document last modified <!--#flastmod file="index.html" -->
This file last modified <!--#flastmod file="ssi.shtml" -->
<!--#include virtual="/footer.html" -->
can use any other variable, including <a href="/env.html">environment variables</a> or the variables
<code class="module"><a href="/mod/mod_include.html">mod_include</a></code> provides an <code>if</code>,
available to you, see the <code class="module"><a href="/mod/mod_include.html">mod_include</a></code>
<p><span>Available Languages: </span><a href="/en/howto/ssi.html" title="English"> en </a> |
<p class="apache">Copyright 2009 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>
<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>