让Apache支持shtml实现include文件解析的配置方法

1. 确认加载include.so模块,将注释去掉: 
LoadModule include_module libexec/apache2/mod_include.so 

2. AddType部分去掉这两段注释: 
AddType text/html .shtml 
AddOutputFilter INCLUDES .shtml 

3. Directory目录权限里面找到 
Options Indexes FollowSymLinks 
增长Includes修改成: 
Options Indexes FollowSymLinks Includes 

4. 从新启动Apache,测试: 

<!–#include file=”head.html”–> 
Holle Word!,这是中间的内容 
<!–#include file=”foot.html”–> 

如下是其它网友的补充: 

什么是SSI? 
SSI是英文Server Side Includes的缩写,翻译成中文就是服务器端包含的意思。从技术角度上说,SSI就是在HTML文件中,能够经过注释行调用的命令或指针。SSI具备强大的功能,只要使用一条简单的SSI命令就能够实现整个网站的内容更新,时间和日期的动态显示,以及执行shell和CGI脚本程序等复杂的功能。 

如何使你的Apache服务器支持SSI? 

Apache默认是不支持SSI的,须要咱们更改httpd.conf来进行配置。我这里以windows平台的Apache 2.0.x为例,打开conf目录下的httpd.conf文件,搜索“AddType text/html .shtml”,搜索结果: html

复制代码代码以下:

# AddType text/html .shtml 
# AddOutputFilter INCLUDES .shtml 



把这两行前面的#去掉。 

而后搜索“Options Indexes FollowSymLinks” 
在搜索到的那一行后面添加“ Includes” 
即将该行改变为 Options Indexes FollowSymLinks Includes 

保存httpd.conf,重起apache便可。 

到此咱们就完成了对Apache SSI的设置。shell

相关文章
相关标签/搜索