跳至主要内容

路由規則

網站是純靜態檔案,伺服器依照下面的順序尋找請求的路徑。

尋找順序​

以請求 /about 為例:

  1. 同名檔案:網站根目錄下有沒有 about(沒有副檔名的檔案)。
  2. 同名 .html:有沒有 about.html。
  3. 目錄首頁:有沒有 about/index.html。有的話回應 301,跳轉到 /about/,查詢參數會保留。
  4. 退回:回應 404;如果開啟了 SPA 退回,回應根目錄的 index.html。

首頁 / 直接回應 /index.html(或 /index.htm)。請求本身以 / 結尾時(例如 /about/),直接回應該目錄的 index.html,不會再跳轉。

範例​

請求網站裡的檔案結果
/index.html200,index.html
/aboutabout.html200,about.html
/aboutabout/index.html301 到 /about/,然後 200
/about/about/index.html200,about/index.html
/aboutabout.html 和 about/index.html 都有200,about.html
/docs/introdocs/intro.html200
/docs/introdocs/intro/index.html301 到 /docs/intro/
/missing無404,或 SPA 退回

如果 about.html 和 about/index.html 同時存在,.html 優先。

目錄不會列出檔案清單。.js、.css、圖片、字型等靜態資源依原路徑直接回應。


延伸:自訂 404、網站設定