基于URI条件SSI [英] Conditional SSI Based on URI

查看:194
本文介绍了基于URI条件SSI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我重做了包括我的网站的网页数十个导航栏。之一的,我要进行更改是改变所包含,基于该用户是在网页上的内容。因此,我的计划基本上是有一个目前包括随处可见作为一个选择决定哪些实际的文件(S)包含文件。

从我的 Apache的SSI规格的阅读,我相信我可以通过有条件的前pressions驾驶我的SSI做到这一点。是这样的:

 <! - #如果expr =[URI是page1.shtml] - >
<! - #包括虚拟=page1contents.shtml - >
<! - #elif的EXPR =[URI是page2.shtml] - >
<! - #包括虚拟=page2contents.shtml - >
<! - #ENDIF - >

我的问题,那么,什么是应该在 [URI是第1页] 的一部分来实际测试我感兴趣的状态?


解决方案

在发现的 mod_include负责


  

下面的例子将打印中富
  如果DOCUMENT_URI是/foo/file.html,
  在酒吧,如果它是/bar/file.html和
  既不,否则:


 <! - #如果expr =$ DOCUMENT_URI=/foo/file.html' - >
在富
<! - #ELIF EXPR =$ DOCUMENT_URI=/bar/file.html' - >
在酒吧
<! - #别的 - >
既不
<! - #ENDIF - >

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?

解决方案

Found the answer in the details of mod_include:

The below example will print "in foo" if the DOCUMENT_URI is /foo/file.html, "in bar" if it is /bar/file.html and "in neither" otherwise:

<!--#if expr='"$DOCUMENT_URI" = "/foo/file.html"' -->
in foo
<!--#elif expr='"$DOCUMENT_URI" = "/bar/file.html"' -->
in bar
<!--#else -->
in neither
<!--#endif -->

这篇关于基于URI条件SSI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆