ssi(Server Side Includes)介绍
Server Side Includes (SSI) is a simple interpreted server-side scripting language used almost exclusively for the Web.
The most frequent use of SSI is to include the contents of one or more files into a web page on a web server. For example, a web page containing a daily quotation could include the quotation by placing the following code into the file of the web page:
<!--#include virtual="../quote.txt" -->
With one change of the quote.txt file, all pages including the file will display the latest daily quotation. The inclusion is not limited to files, and may also be the text output from a program, or the value of a system variable such as the current time.
Server Side Includes are useful for including a common piece of code throughout a site, such as a page header, a page footer and a navigation menu. Conditional navigation menus can be conditionally included using control directives.
In order for a web server to recognize an SSI-enabled HTML file and therefore carry out these instructions, either the filename should end with a specialextension, by default .shtml, .stm, .shtm, or, if the server is configured to allow this, set the execution bit of the file.
As a simple programming language, SSI supports only one type: text. Its control flow is rather simple, choice is supported, but loops are not natively supported and can only be done by recursion using include or using HTTP redirect. The simple design of the language makes it easier to learn and use than most server-side scripting languages, while complicated server-side processing is often done with one of the more feature-rich programming languages. SSI is Turing complete.[1]
Apache, nginx, lighttpd and IIS are the four major web servers that support this language.
SSI has a simple syntax: <!--#directive parameter=value parameter=value -->. Directives are placed in HTML comments so that if SSI is not enabled, users will not see the SSI directives on the page, unless they look at its source. Note that the syntax does not allow spaces between the leading "<" and the directive. [2]
Contents
[hide]
Directives[edit]
Most common directives[edit]
| Directive | Parameters | Description | Example |
|---|---|---|---|
| include | file or virtual | This is probably the most used SSI directive, allowing the content of one document to be included in another. The file or virtual parameters specify the file (HTML page, text file, script, etc.) to be included. Includes the contents of another file or the result of running a CGI script. If the process does not have access to read the file or execute the script, the include will fail. "virtual" specifies the target relative to the domain root, while "file" specifies the path relative to the directory of the current file. When using "file" it is forbidden to reference to absolute paths. Higher directories (..) are usually forbidden, unless explicitly configured. The Apache documentation recommends using "virtual" in preference to "file". | <!--#include virtual="menu.cgi" -->or <!--#include file="footer.html" -->
Apache tutorial on SSI stipulates the format requires a space character before the "-->" that closes the element. |
| exec | cgi or cmd | This directive executes a program, script, or shell command on the server. The cmd parameter specifies a server-side command; the cgi parameter specifies the path to a CGIscript. The PATH_INFO and QUERY_STRING of the current SSI script will be passed to the CGI script, as a result "exec cgi" should be used instead of "include virtual". | <!--#exec cgi="/cgi-bin/foo.cgi" -->or <!--#exec cmd="ls -l" --> |
| echo | var | This directive displays the contents of a specified HTTP environment variable. Variables include HTTP_USER_AGENT, LAST_MODIFIED, and HTTP_ACCEPT. | <!--#echo var="REMOTE_ADDR" --> |
| config | timefmt, sizefmt, or errmsg | This directive configures the display formats for the date, time, filesize, and error message (returned when an SSI command fails). | <!--#config timefmt="%y %m %d" -->or <!--#config sizefmt="bytes" -->or <!--#config errmsg="SSI command failed!" --> |
| flastmod or fsize | file or virtual | These directives display the date when the specified document was last modified, or the specified document's size. The file or virtual parameters specify the document to use. The file parameter defines the document as relative to the document path; the virtual parameter defines the document as relative to the document root. | <!--#flastmod virtual="index.html" -->or <!--#fsize file="script.pl" --> |
| printenv | This directive outputs a list of all variables and their values, including environmental and user-defined variables. It has no attributes. | <!--#printenv --> |
Control directives[edit]
| Directive | Parameters | Description | Example |
|---|---|---|---|
| if | expr | Used for condition tests that may determine and generate multiple logical pages from one single physical page. | <!--#if expr="${Sec_Nav}" --><!--#include virtual="" --><!--#endif --> |
| elif | expr | Serves the same purpose as further conditioning in programming languages. | <!--#if expr="${Sec_Nav}" --><!--#include virtual="secondary_nav.txt" --><!--#elif expr="${Pri_Nav}" --><!--#include virtual="primary_nav.txt" --><!--#endif --> |
| else | If none of the if and elif directive catches the present condition, things in here should happen. | <!--#if expr="${Sec_Nav}" --><!--#include virtual="secondary_nav.txt" --><!--#else --><!--#include virtual="article.txt" --><!--#endif --> |
|
| endif | See above for example. | ||
| set | var, value | Sets the value of a SSI variable. (Not supported by all implementations) | <!--#set var="foo" value="bar" --> |
The <!--#set --> command is supported in both Apache httpd and lighttpd.
reference from:http://en.wikipedia.org/wiki/Server_Side_Includes
ssi(Server Side Includes)介绍的更多相关文章
- 翻译1-在SQL Server 2016中介绍微软R服务
在SQL Server 2016中介绍微软R服务 源自:http://www.sqlservercentral.com/articles/Microsoft/145393/ 作者:tomakatrun ...
- SSI(Server Side Include)简单介绍
Server-side include(server端包含) Server-side include(server端包含)是浏览器向server请求您的文档时并入您的文档的一个文件. 当訪问者浏览器请 ...
- SQL Server群集知识介绍
集群CLUSTER种类介绍 基于iSCSI的SQL Server 2012群集测试(一)--SQL群集安装 SQL Server群集如何在线检测 群集中的MS DTC分布式事务协调器 一.SQL Se ...
- server.xml配置介绍
server.xml位于$TOMCAT_HOME/conf目录下,是Tomcat中最重要的配置文件,server.xml的每一个元素都对应了Tomcat中的一个组件:通过对xml文件中元素的配置,可以 ...
- 第三篇——第二部分——第一文 SQL Server镜像简单介绍
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/DBA_Huangzj/article/details/26951563 原文出处:http://bl ...
- [转]SQL Server编程:SMO介绍
转自:周公 最近在项目中用到了有关SQL Server管理任务方面的编程实现,有了一些自己的心得体会,想在此跟大家分享一下,在工作中用到了SMO/SQL CLR/SSIS等方面的知识,在国内这方面的文 ...
- 【转】Spark History Server 架构原理介绍
[From]https://blog.csdn.net/u013332124/article/details/88350345 Spark History Server 是spark内置的一个http ...
- SQL Server常见数据类型介绍
数据表是由多个列组成,创建表时必须明确每个列的数据类型,以下列举SQL Server常见数据类型的使用规则,方便查阅. 1.整数类型 int 存储范围是-2,147,483,648到2,147,483 ...
- SQL Server存储过程多角度介绍
什么是存储过程: 存储过程(Procedure)类似于C#语言中的方法,它是SQL语句和控制流语句的预编译集合.存储过程存储在数据库内,可由应用程序通过一个调用执行,而且允许用户声明变量.逻辑控制语句 ...
随机推荐
- 在redhat6.4下安装 Oracle® Database 11g Release 2
OS版本: 安装过程的相关信息: pdksh 安装好后根据需要设置oracle开机自启动http://www.cnblogs.com/softidea/p/3761671.html 设置环境变量NLS ...
- RESTFul API 一些文章
http://www.ibm.com/developerworks/cn/web/1103_chenyan_restapi/index.html
- 指令 scope
angular学习笔记(三十)-指令(8)-scope <!DOCTYPE html> <html ng-app="myApp"> <head> ...
- win7无法识别U盘,驱动信息:该设备的驱动程序未被安装。 (代码 28)
台式机的win7 64位系统可以识别u盘,但笔记本的win7 64位却识别不了,说明U盘是可以用的.查看笔记本的设备管理器,发现驱动安装失败,提示信息为“该设备的驱动程序未被安装. (代码 28) ” ...
- Android学习之路——简易版微信为例(三)
最近好久没有更新博文,一则是因为公司最近比较忙,另外自己在Android学习过程和简易版微信的开发过程中碰到了一些绊脚石,所以最近一直在学习充电中.下面来列举一下自己所走过的弯路: (1)本来打算前端 ...
- Servlet能读到JSessionID,读不到其它cookie问题
Servlet的Cookie值保存与获取 今天测试设置和获取Cookie遇到了一点小问题,很奇怪的问题: 把J2ee服务部署在本地 8080端口:访问任何一个服务时,如果客户端没有cookie,则下发 ...
- HDOJ-ACM1012(JAVA)
这道题很简单,主要是弄懂题意和注意输出: 输出的完整结果如下: n e - ----------- 0 1 1 2 2 2.5 3 2.666666667 4 2.708333333 5 2.7166 ...
- KMP学习总结
初学,理解可能不是那么准确~~ Next数组的含义:next[i]表示第0个元素到第i个元素组成的字符串的最大前缀后缀.Next[0]=0显然. 所以KMP的原理就是 通过找出每一阶段最大的相等的前缀 ...
- Yii防注入攻击笔记
网站表单有注入漏洞须对所有用户输入的内容进行个过滤和检查,可以使用正则表达式或者直接输入字符判断,大部分是只允许输入字母和数字的,其它字符度不允许:对于内容复杂表单的内容,应该对html和script ...
- 多组radio传值注意事项
多组radio传值,每组的radio name必须不同,否则所有的radio将被视为一组,传值时只会传其中一组的值到后台,如果这时你用数组接收从前台传过来的值并使用,就会报数组越界异常