萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 網路安全 >  >> 網路應用技術 >> 應用程式教學

Nginx 啟用 SSI 支援 .shtml 格式設定教學

若需在 Nginx 中使用 Server Side Includes (SSI) 處理 .shtml 檔案,只需修改 nginx.conf 設定檔即可。以下為完整步驟:

設定方法

在 nginx.conf 的 http 區塊中加入下列三行指令:

ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
  • ssi on:啟用 SSI 模組
  • ssi_silent_errors on:隱藏 SSI 處理錯誤訊息,避免輸出到頁面
  • ssi_types text/shtml:指定啟用 SSI 的 MIME 類型為 .shtml

儲存設定檔後,重新載入或重啟 Nginx 使設定生效:

nginx -s reload
# 或
systemctl restart nginx

完成後,Nginx 即可正確解析 .shtml 檔案中的 SSI 指令(如 ),實現頁面片段重用與動態內容嵌入。

copyright © 萬盛學電腦網 all rights reserved