ThinkSSL🔒 一键申购 5分钟快速签发 30天无理由退款 购买更放心 广告
apache开启ssi 打开httpd.conf 1、找到LoadModule include_module modules/mod_include.so,把前面的分号去掉 2、找到下面的代码 ~~~ # 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 #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 ~~~ 3、查找Options Indexes FollowSymLinks ,然后修改为下面的代码 注意,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" --> <!--#include file="/header.html" -->