基于 URI 的条件 SSI
我正在重做包含我网站的几十个页面的导航栏。我想要做出的更改之一是根据用户所在的页面来改变所包含的内容。因此,我的计划基本上是让当前包含在各处的文件充当选择器来决定要包含哪些实际文件。
从我对 Apache SSI 规范 的阅读来看,我相信我可以通过驱动我的 SSI 的条件表达式来执行此操作。类似这样:
<!--#if expr="[URI is page1.shtml]" -->
<!--#include virtual="page1contents.shtml" -->
<!--#elif expr="[URI is page2.shtml]" -->
<!--#include virtual="page2contents.shtml" -->
<!--#endif -->
那么,我的问题是,应该在其中的 [URI is page1]
部分中添加什么内容来实际测试我感兴趣的条件?
I am redoing the navigation bar that is included several dozen of my site's pages. One of the changes that I want to make is to vary the content that is included, based on the page that the user is on. Thus my plan is basically to have the file that is currently included everywhere act as a selector to decide which actual file(s) to include.
From the my reading of the Apache SSI Specs, I believe I can do this through conditional expressions driving my SSI. Something like:
<!--#if expr="[URI is page1.shtml]" -->
<!--#include virtual="page1contents.shtml" -->
<!--#elif expr="[URI is page2.shtml]" -->
<!--#include virtual="page2contents.shtml" -->
<!--#endif -->
My question, then, is what should go in the [URI is page1]
part of that to actually test the condition I'm interested in?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 mod_include 的详细信息中找到了答案:
Found the answer in the details of mod_include:
SSI expr 仍然可以在使用 v 函数或 % 的现代服务器上工作(在 Apache/2.4.18 上测试)。您还可以使用文档名称。
示例(对文档名称进行 if-test):
示例 2(对文档路径进行 if-test):
SSI expr still works on modern servers using the v function or % (tested on Apache/2.4.18). You can also use the document name.
Example (if-test on document name):
Example 2 (if-test on document path):