在Apache下開啓SSI配置

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

發佈了12 篇原創文章 · 獲贊 5 · 訪問量 8萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章