简体   繁体   English

Apache:SSI 内 SSI

[英]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 :内部索引.html

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

Inside include1.shtml :include1.shtml里面:

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

So the tree looks like this: index.html <-- include_1.shtml <-- include_2.shtml所以树看起来像这样: index.html <-- include_1.shtml <-- include_2.shtml

As is, this is not working on my Apache.照原样,这不适用于我的 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.因为它是相关的,我在 Apache 2 上使用 XBitHack,我已经仔细检查了这两个文件是否可以由 web 用户执行。

Help?帮助?

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.我知道这个问题已有四年多的历史了,但是为了像我一样通过 StackOverflow惊人的搜索引擎汁找到它的人的利益,这就是我如何使它工作的。

Under Apache2, you need to know this .在 Apache2 下,你需要知道这个

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) . SSI 文件可能是嵌套的,即包含的文件可能包含额外的 SSI 语句(但在这种情况下,无论 XBitHack 的设置如何,都必须具有 .shtml 后缀)

(Emphasis mine) For me, the solution lay in uncommenting two lines in the default httpd.conf : (强调我的)对我来说,解决方案在于取消注释默认httpd.conf中的两行:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

… and changing the filename extension of the first-level included file to.shtml: …并将第一级包含文件的文件扩展名更改为.shtml:

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

Boom.繁荣。 Nested SSI works like a champion.嵌套 SSI 就像一个冠军。

Make sure that Apache is actually trying to process the *.shtml files.确保 Apache 实际上正在尝试处理 *.shtml 文件。 Try putting试着放

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

in a *.shtml file and seeing if you get the expected results.在 *.shtml 文件中查看是否获得预期结果。 Do you get the same result in a *.html file?您在 *.html 文件中得到相同的结果吗? If you don't see the dates in both, your configuration is off.如果您在两者中都没有看到日期,则说明您的配置已关闭。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM