.htaccess 允許目錄層級覆蓋伺服器設定,共享主機常無法修改主設定檔時極具價值。本文詳解 8 大常見用法。
Options -Indexes
防止暴露目錄結構與敏感檔案。
Redirect 301 /old/path/file.html https://www.domain.tld/new/path/file.html 瀏覽器更新連結並快取新址。Redirect 307 /old/path/file.html https://www.domain.tld/new/path/file.html 瀏覽器每次仍請求原址,不快取新址。(後續 6 種用法原文未完整列出,包含 PHP 設定調整、快取控制、副檔名處理器變更、檔案傳輸方式修改等。)