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" -->