Configuring your server to permit SSI
To permit SSI on your server, you must have the following directive either in your httpd.conf
file, or in a .htaccess
file:
Apache HTTP Server versions later than 2.2 will not run on any operating system earlier than Windows 2000. Downloading Apache for Windows The Apache HTTP Server Project itself does not provide binary releases of software, only source code. Apache HTTP Server 2.2.22 is available for download here. The CHANGES2.2 file, linked from the download page, is a full list of changes. A condensed list, CHANGES2.2.22 includes only those changes introduced since the prior 2.2 release. A summary of all of the security vulnerabilities addressed in this and earlier releases is also available. An HTTP server like Apache provides access to representations of the resource(s) within its namespace, with each representation in the form of a sequence of bytes with a defined media type, character set, encoding, etc. Each resource may be associated with zero, one, or more than one representation at any given time. Apache is a modular server. This implies that only the most basic functionality is included in the core server. Extended features are available through modules which can be loaded into Apache. By default, a base set of modules is included in the server at compile-time.
This tells Apache that you want to permit files to be parsed for SSI directives. Note that most configurations contain multiple Options
directives that can override each other. You will probably need to apply the Options
to the specific directory where you want SSI enabled in order to assure that it gets evaluated last.
Not just any file is parsed for SSI directives. You have to tell Apache which files should be parsed. There are two ways to do this. You can tell Apache to parse any file with a particular file extension, such as .shtml
, with the following directives:
Apache Http Server Windows
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
One disadvantage to this approach is that if you wanted to add SSI directives to an existing page, you would have to change the name of that page, and all links to that page, in order to give it a .shtml
extension, so that those directives would be executed.
The other method is to use the XBitHack
directive:
XBitHack
tells Apache to parse files for SSI directives if they have the execute bit set. So, to add SSI directives to an existing page, rather than having to change the file name, you would just need to make the file executable using chmod
.
chmod +x pagename.html
A brief comment about what not to do. You'll occasionally see people recommending that you just tell Apache to parse all .html
files for SSI, so that you don't have to mess with .shtml
file names. These folks have perhaps not heard about XBitHack
. The thing to keep in mind is that, by doing this, you're requiring that Apache read through every single file that it sends out to clients, even if they don't contain any SSI directives. This can slow things down quite a bit, and is not a good idea.
Of course, on Windows, there is no such thing as an execute bit to set, so that limits your options a little.
Apache Web Server Version 2.2 8 Download
In its default configuration, Apache does not send the last modified date or content length HTTP headers on SSI pages, because these values are difficult to calculate for dynamic content. This can prevent your document from being cached, and result in slower perceived client performance. There are two ways to solve this:
Apache 2.2 Download
- Use the
XBitHack Full
configuration. This tells Apache to determine the last modified date by looking only at the date of the originally requested file, ignoring the modification date of any included files. - Use the directives provided by
mod_expires
to set an explicit expiration time on your files, thereby letting browsers and proxies know that it is acceptable to cache them.