How to Set Up Server Side Includes in Apache

Setting up server side includes — or SSIs — in Apache is quite easy, we’ll show you how.

Most people set up SSIs to allow them to include text files within their Web pages, like a regular footer or nav bar. Of course you can do other useful things, like echoing a date or even executing CGIs — but first, you have to configure Apache to use server side includes.

The first thing to do is to open up Apache’s main config file — httpd.conf. Under Linux, that’s probably in /etc/httpd/conf/httpd.conf, under Windows, it’s in the “conf” directory under your installation location. Once you’ve got that open, you’ve got to add the following to any directory (marked by tags) for which you want includes to be turned on:

 Options +Include

That tells Apache to “turn on” SSIs for that directory (and every directory underneath it). Most people do this at the top level of their site, so that SSIs are turned on in every directory of their site. Next, you have to tell Apache which files to evaluate (or parse) for server side includes — usually, you wouldn’t want your server to parse every file for SSIs, so you’d limit it like this:

 AddType text/html .shtml
 AddHandler server-parsed .shtml

The first line says: Add a new type of file, shtml, and give it a mime-type of text/html. The second line says to Apache: any files that end with shtml, parse them for SSIs and send out the resulting document. There are other ways to specify which files should be parsed — one is the XBitHack, which parses all files who’s permissions are set as “executable.” For more on the XBitHack, see

Once you’ve updated your config, restart Apache, and you should be good to start using SSIs. Here are some simple, frequently used SSI examples:

Include a File:


Print Today’s Date:

 Today is 

Include results of a CGI program:


Spread the love