天天看點

Apache 建立虛拟目錄和設定預設頁面

1.找到"conf/httpd.conf" 檔案

2.在httpd.conf裡面加了如下語句

Alias  /anstyla  "E:/anstyla/src/web"

<Directory "E:/anstyla/src/web"> 

          Options Indexes MultiViews 

          AllowOverride None 

          Order allow,deny 

          Allow from all 

</Directory>

在此子產品下建立虛拟目錄,Alias /虛拟目錄名稱/ "虛拟目錄路徑,以[/]代替[\]"

例如:Alias /admin "D:/web/admin/"

(*)/admin 為虛拟目錄名稱,一般不用在名稱後加"/",若加入,每次都要在虛拟目錄後輸入"/"才能通路網站;D:/web/admin/ 為虛拟目錄的實體路徑.

3.重新開機Apache

這步最重要,常常忘了,呵呵.

設定預設頁面

方法1 設定全局的:

<IfModule dir_module>

    DirectoryIndex index.php index.php4 index.php3 index.cgi index.pl index.html index.htm index.shtml index.phtml

default.php

</IfModule>

方法2 針對某一目錄可以這麼設定:

Alias  /anstyla  "E:/anstyla/src/web"

<Directory "E:/anstyla/src/web"> 

          Options Indexes MultiViews 

          AllowOverride None 

          Order allow,deny 

          Allow from all 

          DirectoryIndex default.php

</Directory>

=====================================================

Apache 用的少,怎麼設定虛拟目錄和預設頁面老是忘了,今天記下先.