WEB

apache 下开启SSI配置,支持shtml

Posted by Elli0t on 2020-03-08

先在mods-available里lninclude.load一下到mods-enabled中,再在apache2.conf中配置

增加以下两行:

1
2
AddType text/html .shtml .html .htm
AddOutputFilter INCLUDES .shtml .html .htm

同时:
Options Indexes FollowSymLinks MultiViews +Includes 一行 +Includes一定要有,默认是有的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
配置完的配置文件大致是:
<VirtualHost *:80>
ServerAdmin wayswang@gmail.com
DocumentRoot /var/www/blogguy.cn
ServerName blogguy.cn
ServerAlias
<Directory /var/www/blogguy.cn>
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride None
Order allow,deny
allow from all
AddType text/html .shtml .html .htm
AddOutputFilter INCLUDES .shtml .html .htm
</Directory>
ErrorLog /var/log/apache2/blogguy_cn_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/blogguy_cn_access.log combined
</VirtualHost>

引入的文件的格式如下:
<!--#include virtual='../include/p.html'-->
exec 示范:
<!--#exec cmd="cat /etc/passwd"-->将会显示密码文件

参考文章

Ubuntu自带的apache开启ssi支持shtml|配置-Apache教程
Apache下开启SSI配置,使html支持include包含
ssi的使用 开启 配置等