最新消息:Done.cc 大杂烩。

在nginx下使用ssi包含文件

所有文章 Huishu 14918浏览 0评论

nginx服务器,如何支持ssi包含文件。

主要是三个参数,ssi,ssi_silent_errors和ssi_types,均可以放在http,server和location的作用域下。

ssi on
开启ssi支持,默认是off

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

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

SSI的格式:
<!–#include file=”bottom.htm”–>

<!–#include virtual=”/hx/bottom.htm”–>
路径是相对server中root根目录。

更多请参见官方文档:http://wiki.nginx.org/NginxChsHttpSsiModule

示例:

1.开启shtml后缀的文件名支持ssi
server{
……
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
}

2.开启html后缀的文件名支持ssi
server{
……
ssi on;
ssi_silent_errors on;
}

3.在zt目录下开启html后缀的文件名支持ssi
server{
……
location /hx/{
ssi on;
ssi_silent_errors on;
}
}

转载请注明:Done.cc » 在nginx下使用ssi包含文件

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址