Apache:SSI 中的 SSI

发布于 2024-07-15 00:50:03 字数 520 浏览 14 评论 0原文

有没有办法可以将包含文件包含在包含文件中? (快说五倍!)

例如:

index.html 内部:

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

include1.shtml 内部:

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

所以树看起来像这样: index.html < -- include_1.shtml <-- include_2.shtml

事实上,这在我的 Apache 上不起作用。 第一个包含工作正常,但嵌套包含的内容不显示。

相关的是,我在 Apache 2 上使用 XBitHack,并且我已经仔细检查了这两个文件是否可由 Web 用户执行。

帮助?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终陌 2024-07-22 00:50:09

确保 Apache 实际上正在尝试处理 *.shtml 文件。 尝试放入

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

*.shtml 文件并查看是否获得预期结果。 您在 *.html 文件中得到相同的结果吗? 如果您在两者中都没有看到日期,则说明您的配置已关闭。

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.

川水往事 2024-07-22 00:50:06

我知道这个问题已有四年多了,但为了像我一样通过 StackOverflow 的令人惊叹的搜索引擎能力找到这个问题的人们的利益,我介绍了它的工作原理。

在 Apache2 下,您需要了解这一点

相关文字:

此命令将包含文件的文本插入到已解析的文件中。 SSI 文件可以嵌套,即包含的文件可能包含附加的 SSI 语句(但在这种情况下,无论 XBitHack 的设置如何,都必须具有 .shtml 后缀)。< /p>

(强调我的)对我来说,解决方案在于取消默认 httpd.conf 中两行的注释:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

... 并将第一级包含文件的文件扩展名更改为 .shtml:

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

Boom! 嵌套 SSI 的工作方式就像冠军一样。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文