標籤:
開啟SSI:html、shtml頁面include網頁檔案
使用SSI(Server Side Include)的html副檔名,SSI(Server Side Include),通常稱為"伺服器端嵌入"或者叫"伺服器端包含",是一種類似於ASP的基於伺服器的網頁製作技術。預設副檔名是 .stm、.shtm 和 .shtml。
環境:Apache2.2 (httpd.conf檔案)配置 html、shtml來include網頁檔案
1、 去掉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
2、尋找Options Indexes FollowSymLinks 在後面加上INCLUDES
注意,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" -->
在Apache下開啟SSI配置