需求:Apache安裝在C盤,可是C盤沒有空間,D盤有更多空間 在D盤的一個文件夾下的網頁html,php,當作網站管理 1)添加虛擬目錄的節點 # 配置虛擬目錄 <IfModule dir_module> # directory 至關因而歡迎頁面 DirectoryIndex index.html index.htm index.php # 你的站點別名 Alias /myblog "D:/myblog" # Directory d:/myblog 表示對d:/myblog文件夾設置權限 # 其餘文件夾不設置 <Directory d:/myblog> # 這是訪問權限設置 # 權限執行順序 先allow 再deny order allow,deny # 容許全部ip Allow from all </Directory> </IfModule> 2)註銷documentroot路徑 # DocumentRoot "C:/Program Files/Apache/htdocs" 3)測試 http://localhost/myblog/news.html 4)設置歡迎頁面 http://localhost/myblog/ DirectoryIndex news.html index.html index.htm index.php 5)Apache訪問權限 order deny,allow # 先拒絕全部,再容許全部 allow from 218.20.253.2 # 容許218.20.253.2訪問 deny from 218.20 # 拒絕218.20開頭ip訪問 以上表示 拒絕218.20開頭的ip,可是容許218.20.253.2訪問 以及218.20之外的ip能夠訪問 order allow,deny # 先容許全部,再拒絕全部 deny from 218.20 # 拒絕218.20開頭ip allow from 218.20.253.2 # 容許218.20.253.2開頭ip訪問 以上表示 拒絕全部ip訪問