Nerdrium Home



Web Design

Case Mods





My Blog




Apache 2.0 Settings for Server-Side Includes

by Michael Greifenkamp (June 6th, 2003)

Do you run your own server? Have you been dying to use server-side include files ever since reading my brief explanation of them?

Did it not work properly? There's a good chance that it won't, for several reasons.

For starters, Apache has to be told that include files are going to be used. It took me a while to figure this out using the Apache software documentation, but since I have figured it out, and it is rather simple, I figured I'd share it with you.

Note: any time you modify the httpd.conf file in Apache it's a good idea to shut the service down first...

Telling Apache to use includes is easy. Open up the httpd.conf file using your favorite text editor (I use vi editor) and add this line to the top:

Options +Includes

This tells Apache that you would like it to be aware of include files and to parse them accordingly.

You might need (want?) another step, however. To save processing power, most Linux/Apache servers are set up so that not all files are parsed for SSI before being dished back to a user's browser. This means that you'll need to use the extension ".shtml" at the end of each of your pages that you want to use SSI. Adding SSI to a regular .html file won't do anything--the "include" will be ignored.

If, like me, you want to use SSI on every page that you create, you don't need to use the .shtml extension. Just tell Apache to check ALL pages that it serves for SSI before serving them. Add the following lines to your httpd.conf file:

AddType text/html .html
AddOutputFilter INCLUDES .html

Now Apache knows to parse all .html files, and not just .shtml files. This way you can add includes to all of your web pages, and Apache will know what to do with them.

Have fun!