您的位置:首页 > 运维架构 > Apache

在Apache下开启SSI配置

2017-06-15 22:10 363 查看

在Apache下开启SSI配置

开启SSI:html、shtml页面include网页文件
 
使用SSI(Server Side Include)的html文件扩展名,SSI(Server Side Include),通常称为"服务器端嵌入"或者叫"服务器端包含",是一种类似于ASP的基于服务器的网页制作技术。默认扩展名是 .stm、.shtm 和 .shtml。
 
环境:Apache2.2 (httpd.conf文件)配置 html、shtml来include网页文件
1、 去掉AddType text/html .shtml ,AddOutputFilter INCLUDES .shtml前面注释

    # 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 .shtml .html

    AddOutputFilter INCLUDES .shtml .html
2、查找Options Indexes FollowSymLinks 在后面加上INCLUDES
注意,SSI确实可以利用shell来执行命令,这个功能是极度危险的,因为它会执行任何包含在exec标记中的命令。如果用户有可能修改你的网页内容,那么你一定要关闭这个功能。可以在Options指令中加上IncludesNOEXEC参数,以关闭exec功能,同时又保留SSI。
<Directory "E:/website">  #修改E:/website网站目录
#    Options FollowSymLinks

#    AllowOverride None

#    Order deny,allow

#    Deny from all

      Options FollowSymLinks INCLUDES IncludesNOEXEC
      AllowOverride None

</Directory>
3、重新启动apache ,ok你的html、shtml就可以加载页面了。
4、用include命令包含页面。
include元素能按file属性或virtual属性判断应该包含的文件。file属性是一个相对于当前目录的文件路径,即不能是一个绝对路径(以"/"开头)或包含"../"的路径。virtual属性可能更有用,它是一个相对于被提供的文档的URL ,可以以"/"开头,但必须与被提供的文档位于同一服务器上。
<!--#include virtual="/header.html" -->
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: