2015-02-24 101 views
2

我是一名Web開發人員,經常希望查看本地計算機上的不同項目。目前我的本地主機設置爲「C:/ xampp/htdocs /」。我想創建一個指向「C:/ xampp/htdocs/company /」的「company.localhost」。本地主機,子域,使用XAMPP

我已經編輯C:\ WINDOWS \ SYSTEM32 \ DRIVERS \等\主機包括行

127.0.0.1 company.localhost 

我已經編輯C:\ XAMPP的\ apache的\的conf \額外\的httpd-vhosts.conf來包括

<VirtualHost *:80> 
    ServerName company.localhost 
    ServerAlias company.localhost 
    DocumentRoot "C:/xampp/htdocs/company/" 
    DirectoryIndex index.php index.html index.htm index.shtml 
</VirtualHost> 

當我瀏覽到http://company.localhost在我的瀏覽器(使用Chrome),它讓我看到本地主機索引頁。我已經啓動並重新啓動了我的Apache服務器。我如何在瀏覽器中訪問company.localhost/index.php?

我在Windows 7

編輯:現在無論是http://localhosthttp://company.localhost都指向索引頁company.localhost。我如何獲取正常的本地主機索引並仍然保留company.localhost的正確索引頁?

謝謝。

+0

也許有幫助,在Windows上使用\而不是/ – lmarcelocc 2015-02-24 17:02:36

+0

我被複制的虛擬主機文件中的例子,但我給它一個鏡頭。編輯:現在它告訴我網頁不可用。 – ShiningLight 2015-02-24 17:04:14

+0

使用反斜槓代替正斜槓會導致Apache突然停止的錯誤。 – ShiningLight 2015-02-24 17:10:51

回答

0

在同一端口上創建多個虛擬主機時,必須指定每個主機名。否則,只有一個站點綁定到端口80,所有本地主機調用將直接指向您指定的文件夾。

這裏是缺少的代碼,在c:\ xampp \ apache \ conf \ extra \ httpd-vhosts.conf中的類似代碼之前或之後添加。

<VirtualHost *:80> 
    ServerName localhost 
    ServerAlias localhost 
    DocumentRoot "C:/xampp/htdocs/" 
    DirectoryIndex index.php index.html index.htm index.shtml 
</VirtualHost>