Friday, 2 March 2007

Setting up xssi parsing for included files

I've set this up a few times now and sometimes it takes me a while to remember what steps were required to make this work... so here are some rough notes:

httpd.conf must have the mod_include module loaded (so this needs to be copied / compiled if not in there automatically)

LoadModule include_module path/to/apache/mods/

"Include" needs to be added to your options

Options Indexes FollowSymLinks Includes

<IfModule mime_module>
# this section should contain the following:

AddType text/html .shtml .sssi
AddOutputFilter INCLUDES .shtml .sssi

# so any includes named *.sssi will be parsed by apache

After an apachectl restart, you can make a page called test.shtml which contains this call:

<!--#include file="includes/footer.sssi" -->

And footer.sssi can contain something like this:

<!--#if expr="{$QUERY_STRING} = /printenv/" -->
<div id="debug-footer">
<h3>Debug Footer</h2>
<p>File last modified <!--#flastmod file="$DOCUMENT_NAME" --></p>
<pre><!--#printenv --></pre>
<!--#else -->
<h3>Standard Footer</h3>
<!--#endif -->

Now when you open test.shtml?printenv you'll see your environment variables.

No comments: