在SHTML中通过SSI指令实现文件动态包含

文章地址: http://blog.csdn.net/5iasp/article/details/12992769

作者: javaboy2012
Email:yanek@163.com
qq:    1046011462

 

在SHTML中通过SSI指令实现文件动态包含

代码如下:

测试代码:

假设文件为index.shtml 内容如下:

<!--#if expr="$QUERY_STRING='id=1'" --> 
<!--#include virtual="/test/1.inc" -->
<!--#endif --> 

<!--#if expr="$QUERY_STRING='id=2'" --> 
<!--#include virtual="/test/2.inc" -->
<!--#endif --> 


<!--#if expr="$QUERY_STRING=''" --> 
<!--#include virtual="/test/3.inc" -->
<!--#endif --> 


 

有如下三个被包含的文件。

http://www.myweb.com/test/1.inc
http://www.myweb.com/test/2.inc
http://www.myweb.com/test/3.inc

index.shtml的发布路径:

http://www.myweb.com/index.shtml

http://www.myweb.com/test/index.shtml?id=2  则执行后显示包含2.inc的内容
http://www.myweb.com/test/index.shtml?id=1  则执行后显示包含1.inc的内容
http://www.myweb.com/test/index.shtml       则执行后显示包含3.inc的内容


通过如上处理则可以实现实现在服务器端实现动态包含。

在apache服务器下测试通过。

 

参考资料: http://apache.jz123.cn/howto/ssi.html

ssi参考文档 : http://download.csdn.net/detail/5iasp/6445779

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值