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

網站訪問出現「Directory Listing Denied」錯誤原因與解決方法

編輯:關於伺服器

瀏覽器訪問網站顯示:

Directory Listing Denied
This Virtual Directory does not allow contents to be listed.

**核心原因:IIS 目錄瀏覽功能未啟用,且該目錄下不存在預設文檔 (Default Document)。** IIS 預設安全策略禁止列出目錄內容,必須有預設文檔才能直接訪問網站根目錄。

快速解決 (三選一)

  1. 上傳預設文檔 (最簡單、推薦): 在網站根目錄 (如 wwwroot, public_html, D:\Web\Site) 放入任一預設文檔檔名:
index.html
index.htm
index.asp
index.aspx
index.php
default.html
default.htm
default.asp
default.aspx
default.php

檔名**大小寫不敏感** (Windows),但建議全小寫。上傳後重新整理瀏覽器即可正常顯示。

  1. 在 IIS 中添加/調整預設文檔順序:
  • IIS 管理員 → 選取站點 → 功能視圖雙擊「預設文檔」
  • 右側動作欄「添加」→ 輸入您的首頁檔名 (如 home.html)
  • 用「上移」將其移至頂部優先順位
  1. 啟用目錄瀏覽 (不推薦生產環境,洩露檔案結構):
  • IIS 管理員 → 站點 → 「目錄瀏覽」→ 右側「啟用」
  • 訪問網站將顯示檔案列表 (如 Apache Options Indexes)

虛擬主機/共享主機環境特殊說明

  • 主機商通常預設建立 index.html、default.aspx 等佔位檔
  • 若您刪除了預設文檔且未上傳新首頁,即會出現此錯誤
  • 請確認 FTP/檔案管理器中網站根目錄**確實存在**上述任一預設文檔檔名

進階:URL Rewrite 重寫首頁 (無實體預設文檔)

若使用 MVC/單頁應用 (SPA) 無實體 index.html,可用 URL Rewrite 重寫至入口點:


  
    
      
        
          
          
            
            
          
          
        
      
    
  

「Directory Listing Denied」不是錯誤,是 **IIS 安全預設行為**。**上傳正確檔名的預設文檔** 即可秒解。生產環境**請勿啟用目錄瀏覽**,避免洩露敏感檔案結構、備份檔、配置檔等資訊。

Copyright © Windows教程網 All Rights Reserved