apache和nginx支持SSI配置

默北 Nginx web应用321,6523字数 1236阅读4分7秒阅读模式

一. 前言

SSI是一种类似于ASP的基于服务器的网页制作技术。将内容发送到浏览器之前,可以使用“服务器端包含 (SSI)”指令将文本、图形或应用程序信息包含到网页中。例如,可以使用 SSI 包含时间/日期戳、版权声明或供客户填写并返回的表单。对于在多个文件中重复出现的文本或图形,使用包含文件是一种简便的方法。将内容存入一个包含文件中即可,而不必将内容输入所有文件。通过一个非常简单的语句即可调用包含文件,此语句指示 Web 服务器将内容插入适当网页。而且,使用包含文件时,对内容的所有更改只需在一个地方就能完成。
因为包含 SSI 指令的文件要求特殊处理,所以必须为所有 SSI 文件赋予 SSI文件扩展名。默认扩展名是 .stm、.shtm 和 .shtml

二. apache配置

apache默认不支持ssi的,可以在apache下做如下设置:
修改Apache配置文件httpd.conf
1. 确认加载include.so模块,将注释去掉:文章源自运维生存时间-https://www.ttlsa.com/web/apache-and-nginx-support-ssi-configuration/

LoadModule include_module libexec/apache2/mod_include.so

2. AddType部分去掉这两段注释:文章源自运维生存时间-https://www.ttlsa.com/web/apache-and-nginx-support-ssi-configuration/

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

3. Directory目录权限里面找到文章源自运维生存时间-https://www.ttlsa.com/web/apache-and-nginx-support-ssi-configuration/

Options Indexes FollowSymLinks
增加Includes修改为:
Options Indexes FollowSymLinks Includes

4. 重新启动Apache文章源自运维生存时间-https://www.ttlsa.com/web/apache-and-nginx-support-ssi-configuration/

三. nginx配置

1. 相关指令说明:
ssi
语法:ssi [ on | off ]
默认值:ssi off
配置段段:http, server, location, if
启用SSI处理。
[warning]注意如果启用SSI,那么Last-Modified头和Content-Length头不会传递。[/warning]文章源自运维生存时间-https://www.ttlsa.com/web/apache-and-nginx-support-ssi-configuration/

ssi_silent_errors
语法:ssi_silent_errors [on|off]
默认值:ssi_silent_errors off
配置段:http, server, location
如果在处理SSI的过程中出现“[an error occurred while processing the directive]”错误,禁止将其输出。文章源自运维生存时间-https://www.ttlsa.com/web/apache-and-nginx-support-ssi-configuration/

ssi_types
语法:ssi_types mime-type [mime-type …]
默认值:ssi_types text/html
配置段:http, server, location
默认只解析text/html类型,这个参数可以指定其他的MIME类型。文章源自运维生存时间-https://www.ttlsa.com/web/apache-and-nginx-support-ssi-configuration/

ssi_value_length
语法:ssi_value_length length
默认值:ssi_value_length 256
配置段:http, server, location
定义允许SSI使用的参数值的长度。文章源自运维生存时间-https://www.ttlsa.com/web/apache-and-nginx-support-ssi-configuration/

2. 在nginx下做如下设置:
Apache
如需转载请注明出处:https://www.ttlsa.com/html/3134.html文章源自运维生存时间-https://www.ttlsa.com/web/apache-and-nginx-support-ssi-configuration/ 文章源自运维生存时间-https://www.ttlsa.com/web/apache-and-nginx-support-ssi-configuration/

weinxin
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
默北
  • 本文由 发表于 23/09/2013 17:03:03
  • 转载请务必保留本文链接:https://www.ttlsa.com/web/apache-and-nginx-support-ssi-configuration/
评论  3  访客  1
    • […] 8.??ngx_http_core_module模块提供的变量 9.??nginx日志配置 10.?apache和nginx支持SSI配置 12.?nginx日志切割 13.?Nginx重写规则指南 14.?nginx 逻辑运算 […]

    评论已关闭!