Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

IIS MIME 類型完整配置指南:.shtml/.shtm SSI 支援設定與常見 MIME 對照表

編輯:關於伺服器

.shtml / .shtm SSI (伺服器端包含) 啟用完整步驟

Windows Server 2003 + IIS 6.0

  1. IIS 管理員 → 本地電腦 → 右鍵內容 → **MIME 類型** → 新增
    副檔名:.shtml → **MIME 類型**:text/html
    副檔名:.shtm → **MIME 類型**:text/html
  2. **Web 服務擴展** (與網站同層) → 找到 **「在伺服器端的包含檔案」** → 設為 **「允許」**
  3. 重新啟動 IIS (iisreset /restart) → 必須執行,否則不生效

Windows 2000 + IIS 5.0

  1. IIS 管理員 → 網站屬性 → **主目錄** → **配置** → **應用程式對應** → 新增
    **可執行檔**:C:\WINNT\system32\inetsrv\ssinc.dll
    **副檔名**:.shtml (再加一次 .shtm)
    **動詞**:全部/GET,POST → 勾選「腳本引擎」→ 確定
  2. 同樣需在 MIME 類型新增 .shtml/.shtm = text/html
  3. 重啟 IIS

⚠ 核心概念:IIS 定義中 .shtml 屬於 **SSI 元件**,必須同時完成 **MIME 類型註冊** + **應用程式對應/擴展啟用** 雙重設定,單一設定均不生效。

常見 MIME 類型完整對照表 (節選高頻項目)

副檔名MIME 類型說明
.html / .htm / .shtml / .shtmtext/htmlHTML 文件
.csstext/css樣式表
.jsapplication/javascriptJavaScript (標準)
.jsonapplication/jsonJSON 資料
.xmlapplication/xmlXML 文件
.txttext/plain純文字
.pdfapplication/pdfPDF 文件
.zipapplication/zipZIP 壓縮包
.rarapplication/x-rar-compressedRAR 壓縮包
.jpg / .jpeg / .jpeimage/jpegJPEG 圖片
.pngimage/pngPNG 圖片
.gifimage/gifGIF 圖片
.svgimage/svg+xml向量圖形
.icoimage/x-icon網站圖示
.mp4video/mp4MP4 影片
.webmvideo/webmWebM 影片
.mp3audio/mpegMP3 音訊
.wavaudio/wavWAV 音訊
.woff / .woff2font/woff / font/woff2Web 字體
.ttf / .otffont/ttf / font/otfTrueType/OpenType 字體
.apkapplication/vnd.android.package-archiveAndroid 安裝包
.ipaapplication/vnd.iphoneiOS 安裝包
.doc / .docxapplication/msword / application/vnd.openxmlformats-officedocument.wordprocessingml.documentWord 文件
.xls / .xlsxapplication/vnd.ms-excel / application/vnd.openxmlformats-officedocument.spreadsheetml.sheetExcel 文件
.ppt / .pptxapplication/vnd.ms-powerpoint / application/vnd.openxmlformats-officedocument.presentationml.presentationPowerPoint 文件

IIS 版本別 MIME 管理介面差異

IIS 版本管理路徑備註
IIS 6.0 (WS2003)本地電腦 → 內容 → MIME 類型全域設定,影響所有網站
IIS 7.0+ (WS2008+)網站 → 功能視圖 → MIME 類型可網站層級覆寫,繼承全域
IIS 7.0+ 命令列appcmd set config /section:staticContent /+[fileExtension='.xyz',mimeType='application/xyz']適合腳本自動化部署

新增 MIME 類型檢查清單

  1. 副檔名含前綴點 (如 .xyz,非 xyz)
  2. MIME 類型符合 IANA 標準或業界通用值
  3. 無重複副檔名衝突 (同副檔名不同 MIME 會報錯)
  4. **重啟 IIS / 回收應用程式集區** 使生效
  5. 瀏覽器開發者工具 Network 面板驗證 Content-Type 回應標頭正確

安全提醒:禁止執行類 MIME 對上傳目錄的影響

  • 上傳目錄**必須移除** .asp、.aspx、.php、.exe、.dll 等執行類 MIME/處理器對應
  • 或在上傳目錄設定 Handler Mappings 僅允許 StaticFile
  • 配合 web.config <system.webServer><handlers><clear /><add name="StaticFile" ...> 鎖定

MIME 管理鐵律:預設拒絕、顯式允許。僅為確確實實需要的檔案類型註冊 MIME,未註冊的副檔名 IIS 會回傳 404.3 (未註冊的 MIME),這正是安全防護的一環。定期審核 MIME 列表,移除棄用/實驗性類型。

Copyright © Windows教程網 All Rights Reserved