Question

Is there a way I can include include files inside include files? (Say that five times fast!)

For example:

Inside index.html:

<!--#include virtual="/include-1.shtml"-->

Inside include1.shtml:

<!--#include virtual="/include-2.shtml"-->

So the tree looks like this: index.html <-- include_1.shtml <-- include_2.shtml

As is, this is not working on my Apache. The first include works fine, but the content for the nested include doesn't display.

As it is relevant, I am using the XBitHack on Apache 2, and I've double checked that both files are executable by the web user.

Help?

Was it helpful?

Solution

Make sure that Apache is actually trying to process the *.shtml files. Try putting

<!--#echo var="DATE_LOCAL" -->

in a *.shtml file and seeing if you get the expected results. Do you get the same result in a *.html file? If you don't see the dates in both, your configuration is off.

OTHER TIPS

I know that this question is more than four years old, but for the benefit of people who, like me, find it thanks to StackOverflow's amazing search engine juice, here's how I made it work.

Under Apache2, you need to know this.

Relevant text:

This command inserts the text of the included file into the parsed file. SSI files may be nested, that is the included file may contain additional SSI statements (but in this case must have an .shtml suffix irrespective of the setting of XBitHack).

(Emphasis mine) For me, the solution lay in uncommenting two lines in the default httpd.conf:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

… and changing the filename extension of the first-level included file to .shtml:

index.html
  └─┬─ include1.shtml
    └─── include2.html

Boom! Nested SSI works like a champion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top