SSI include file与virtual的区别

简介:

实例:

 

<!--#include file="/dir/file.html" -->

 

<!--#include virtual="/dir/file.html" -->

 

有什么不同?

 

 

相同点: 都能将file.html包含进来.

 

不同点: virtual 包含的职能是纯文件, 而file 文件里面可能有变量定义, 逻辑条件

 

实如:

file.html 的内容是 

 

 

Html代码   收藏代码
  1. <!--#if expr="${SERVER_NAME}=/^(www|images)\.example\.com.*/" -->  
  2.   
  3.     <!--#set var="HTML_HOST" value="http://www.example.com"-->  
  4.     <!--#set var="IMG_HOST" value="http://images.example.com"-->  
  5.   
  6. <!--#else -->  
  7.   
  8.     <!--#set var="HTML_HOST" value="http://${SERVER_ADDR}"-->  
  9.     <!--#set var="IMG_HOST" value="http://${SERVER_ADDR}"-->  
  10.   
  11. <!--#endif -->  

 

 

测试页面a.html

 

 

 

Html代码   收藏代码
  1. <!--#include file="/dir/file.html" -->  
  2. <!--#echo var="IMG_HOST"-->  

 

 

测试页面b.html

 

Html代码   收藏代码
  1. <!--#include virtual="/dir/file.html" -->  
  2. <!--#echo var="IMG_HOST"-->  

 

现在比较两个页面的输出结果

目录
相关文章
|
28天前
|
编译器 程序员 API
【踩坑记录】解决GCC 中C++ 17 的 std::filesystem 链接报错:undefined reference to `std::filesystem::path
【踩坑记录】解决GCC 中C++ 17 的 std::filesystem 链接报错:undefined reference to `std::filesystem::path
52 4
|
1月前
|
PHP
include和require的区别
include和require的区别
31 0
|
3月前
|
消息中间件 Kubernetes NoSQL
c++ std::enable_shared_from_this作用
c++ std::enable_shared_from_this作用
|
10月前
|
数据安全/隐私保护
fatal error: boost/algorithm/string.hpp: 没有那个文件或目录
fatal error: boost/algorithm/string.hpp: 没有那个文件或目录
122 0
|
10月前
|
编译器 C++
【为什么】C++中的#pragma once是干什么,和#include guard区别
【为什么】C++中的#pragma once是干什么,和#include guard区别
|
Unix 应用服务中间件 nginx
安装nginx:src/os/unix/ngx_user.c:26:7: error: ‘struct crypt_data’ has no member named ‘curren
安装nginx:src/os/unix/ngx_user.c:26:7: error: ‘struct crypt_data’ has no member named ‘curren
775 0
安装nginx:src/os/unix/ngx_user.c:26:7: error: ‘struct crypt_data’ has no member named ‘curren
完美解决common_define.h: No such file or directory
完美解决common_define.h: No such file or directory
128 0
完美解决common_define.h: No such file or directory