在nginx、apache、iis中配置SSI

SSI是被HTML文档内需要进行处理的包含部分的SSI Servlet调用的。这些指令是HTML文档的注释形式,这些指令在将内容发送到客户端之前进行内容的替换。标准格式如下:

<!--#directive [parm=value] -->

这些指令包括:

config:设置日期格式一起被SSI处理的其他数据(<!--#config timefmt="%B %Y" -->)

echo:将会被变量的值替换掉(<!--#echo var="VARIABLE_NAEM" -->)

exec:用来执行服务器端的命令

include:包含某些内容(<!--#include virtual="file-name" -->)

flastmod:返回某个文件最后一次修改的时间(<!--#flastmod file="filename.html" -->)

fsize:返回某个文件的大小(<!--#fzie file="filename.html" -->)

printenv:返回所有定义的变量(<!--#printenv -->)

set:用来为定义的变量赋值(<!--#set var="foo" value="Bar" -->)

if elif endif else:创建条件分支语句

nginx启用SSI

nginx的SSI配置选项主要是以下三个:

  • ssi: 默认值off,启用ssi时将其设为on

  • ssi_silent_errors: 默认值off,开启后在处理SSI文件出错时不输出错误提示"[an error occurred while processing the directive]"。

  • ssi_types: 默认是text/html,所以如果需支持html,则不需要设置这句,如果需要支持shtml则需要设置:ssi_types text/shtml


三个参数可以放在http, server或location作用域下。

1
2
3
4
5
6
7
8
9
10
11
12
#静态化站点映射
server {
        listen       80;
        server_name  www.baidu.com;
    index index.html;
    root    /data/www/baidu.com/static/;
    error_page 404 /404.html;
    #开启SSI服务器端包含
    ssi on;
    ssi_silent_errors on;
    access_log  /data/log/nginx/access/baidu.com.log;
}

apache上启用SSI

  • 在apache配置文件(httpd.conf)中配置需要支持SSI的后缀(html)

去掉AddType text/html,AddOutputFilter INCLUDES前面注释

1
2
3
4
5
6
7
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
AddType text/html .html
AddOutputFilter INCLUDES .html
  • 查找Options Indexes FollowSymLinks在后面加上Includes

1
Options Indexes FollowSymLinks Includes


上一篇:FineCMS 内容管理

下一篇:内容模型