在Apache下開啟SSI配置

來源:互聯網
上載者:User

標籤:

開啟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配置

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.