AddOutputFilter 就是针对某一种特定后缀的文件,添加一个处理程序(管道或者拦截器)
今天配置了mac 的 include
按照如下配置设置了Apache 的 SSI 功能
- 确认加载include.so模块,将注释去掉:
LoadModule include_module libexec/apache2/mod_include.so - AddType部分去掉这两段注释:
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml - Directory目录权限里面找到
Options Indexes FollowSymLinks
增加Includes修改为:
Options Indexes FollowSymLinks Includes - 重新启动Apache,测试:
但是发现没有生效,查找原因发现我的代码使用的主页面和子页面都是 html 后缀,但是文档中配置的是 .shtml 后缀,修改后配置文件为:
AddType text/html .html
AddOutputFilter INCLUDES .html
<!--#include virtual="../mod.html" -->
测试没有问题
参考文档: