在SHTML中通过SSI指令实现文件动态包含
文章地址: https://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 -->
有如下三个被包含的文件。
https://www.myweb.com/test/1.inc
https://www.myweb.com/test/2.inc
https://www.myweb.com/test/3.inc
index.shtml的发布路径:
https://www.myweb.com/index.shtml
则
https://www.myweb.com/test/index.shtml?id=2 则执行后显示包含2.inc的内容
https://www.myweb.com/test/index.shtml?id=1 则执行后显示包含1.inc的内容
https://www.myweb.com/test/index.shtml 则执行后显示包含3.inc的内容
通过如上处理则可以实现实现在服务器端实现动态包含。
在apache服务器下测试通过。
参考资料: https://apache.jz123.cn/howto/ssi.html
ssi参考文档 : https://download.csdn.net/detail/5iasp/6445779
最后更新:2017-04-03 14:53:52