欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

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

程序员文章站 2024-02-04 16:39:28
1. 确认加载include.so模块,将注释去掉: loadmodule include_module libexec/apache2/mod_include.so 2....
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”,搜索结果:
复制代码 代码如下:

# addtype text/html .shtml
# addoutputfilter includes .shtml


把这两行前面的#去掉。

然后搜索“options indexes followsymlinks”
在搜索到的那一行后面添加“ includes”
即将该行改变为 options indexes followsymlinks includes

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

到此我们就完成了对apache ssi的设置。