nginx 解析不了 include ,因为未开启SSI

来源:互联网 发布:淘宝第三方资金平台 编辑:程序博客网 时间:2024/04/27 03:50

什么是SSI

SSI 是 Server Side Include 的首字母缩略词,是一种基于服务端的网页制作技术。通过一个非常简单的语句即可调用包含文件,页面传送给浏览器之前,服务器会对页面所包含的文件放回页面中去。

SSI 默认情况下是不开启的,需要用户自己开启。开启所需要的三个参数:ssi,ssi_silent_errors和ssi_types

ssi on; //开启ssi支持,默认是offssi_silent_errors on; //默认值是off,开启后在处理SSI文件出错时不输出错误提示:"[an error occurred while processing the directive]"ssi_types text/shtml; //默认是ssi_types text/html,支持htm和html页面,如果需要shtml支持,则需要设置为:ssi_types text/shtml

我把配置放到 location 作用域下:
这里写图片描述

那么我在 html 页面就可以使用 include 了,如这样引入头部:

<!--#include file="header.html"-->

【参考】
http://blog.csdn.net/qmhball/article/details/8778201
http://www.apelearn.com/bbs/thread-5281-1-1.html
http://www.k68.org/?p=1361

0 0
原创粉丝点击