一些網站系統可能用到了SSI,下面就分別介紹在Apache和IIS開啟如何SSI?
Apache(Linux / Windows 環境通用)
配置 httpd.conf(在 Apache 安裝目錄下的 conf/ 目錄下),看有沒有這兩行,沒有就加上:
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
接下來到你的虛擬主機配置項里,配置如下的一行:
Options -Indexes FollowSymLinks Includes
這個看情況,自己比對一下,有沒有漏掉哪個單詞。
最后附一個虛擬主機的參考配置(提示:不要直接拷貝):
<VirtualHost *:80>
ServerName cmstop.run
DocumentRoot "D:\SERVER\www\cmstop.run"
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
<Directory />
Options -Indexes FollowSymLinks MultiViews Includes
DirectoryIndex index.shtml index.html index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ServerSignature On
</VirtualHost>
Windows 2003 下的 IIS
windows 2003 安裝好 IIS 之后默認是支持 .shtml 的,只要在 “WEB服務擴展” 允許 “在服務器前端的包含文件” 即可,重啟 IIS 使配置生效。
Windows 2000 下的 IIS
打開 IIS,在要配置的網站上點擊右鍵,選擇屬性,并在接下來的窗口中點擊主目錄,再點擊右下方的配置,打開應用程序配置界面,如果列表中不存在 .shtml 和 .shtm,則需要自己手動添加,點擊 添加 按鈕,在打開的窗口中輸入:
可執行文件:C:\WINDOWS\system32\inetsrv\ssinc.dll
擴展名:.shtml或.shtm
限制為:GET,POST
勾選“腳本引擎”和“確認文件是否存在”;
一路確定下去即可完成,之后重啟 IIS 使配置生效。
Nginx下開啟SSI
這個最簡單,在 nginx 的 http 配置節中,添加如下的一行即可:
http
{
...
ssi on;
...
}
之后記得重啟 Nginx。