加載 mod_autoindex 模塊
Apache 2.4版本,如果要控制站點目錄是否顯示,需要 mod_autoindex 模塊。如果沒有該模塊,顯示站點目錄的指令無效。
加載該模塊
LoadModule autoindex_module modules/mod_autoindex.so
方法一
解決過程:首先查看apache官網文檔,不能快速找到需要的部分。用搜索引擎查找“apache顯示站點目錄”,找到相關資料,雷同。按照資料說明配置無效。
開始嘗試在虛擬主機和非虛擬主機嘗試資料中的配置,仍然無效。再回到官網文檔查找關鍵詞“Options Indexes”,看到“mod_autoindex can generate a listing of the directory contents”,
然后全文檢索httpd.conf,意識到是因為相關模塊沒有加載。
虛擬主機顯示站點目錄
apache 2.4版本默認不顯示站點目錄,虛擬主機配置如下:
<VirtualHost *:80>ServerAdmin chuganghong@qq.comDocumentRoot "E:/wamp64/www/my-site/test-php"ServerName test-php.comErrorLog "logs/test-php.com-error.log"CustomLog "logs/test-php.com-access.log" common</VirtualHost>
加入顯示站點目錄的指令 Options +Indexes,完整代碼如下:
<VirtualHost *:80><Directory "E:/wamp64/www/my-site/test-php">Options +Indexes # 顯示站點目錄</Directory>ServerAdmin chuganghong@qq.comDocumentRoot "E:/wamp64/www/my-site/test-php"ServerName test-php.comErrorLog "logs/test-php.com-error.log"CustomLog "logs/test-php.com-access.log" common</VirtualHost>
Options +Indexes 或 Options Indexes 或沒有這條指令,顯示站點目錄。
Options -Indexes,禁止顯示站點目錄。
以上所述是小編給大家介紹的Apache控制是否顯示站點目錄,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對VEVB武林網網站的支持!
新聞熱點
疑難解答