Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache: SSI inside SSI

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?

like image 390
neezer Avatar asked Jul 19 '26 23:07

neezer


1 Answers

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.

like image 57
Dave Land Avatar answered Jul 22 '26 13:07

Dave Land



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!