2011-08-18 109 views
1

我想使用Wamp在本地主機上設置子域。我創建的子域名是store.localhost,現在我可以讓該子域名工作,但是當我使用localhost重定向到store.localhost時,其他任何東西都與localhost相關聯。所以只需http://localhost重定向到store.localhost。創建本地主機子域重定向所有本地主機鏈接

我的主機文件有以下幾點:

127.0.0.1 localhost 

127.0.0.1 store.localhost 

我的httpd-vhosts.conf文件有:

<VirtualHost *:80> 
    DocumentRoot "C:/wamp/www/store" 
    ServerName store.localhost 
    ErrorLog "logs/error.log" 
    CustomLog "logs/access.log" common 
</VirtualHost> 

,我已經註釋掉在httpd.conf中關於虛擬主機的線路。

那麼我做錯了什麼?

回答

0

您是否有另一個使用ServerName localhost定義的VirtualHost?如果沒有,那麼Apache將使用第一個定義的虛擬主機來處理請求,所以你可能要像這樣

#catch all server 
<VirtualHost *:80> 
    DocumentRoot "C:/wamp/www/catchall" 
    ServerName localhost 
</VirtualHost> 

#store.localhost 
<VirtualHost *:80> 
    DocumentRoot "C:/wamp/www/store" 
    ServerName store.localhost 
    ErrorLog "logs/error.log" 
    CustomLog "logs/access.log" common 
</VirtualHost> 

參見named based virtual hosting Apache手冊部分獲得更多。

+0

定義的唯一虛擬主機是商店的虛擬主機。那麼我應該使用你在vhosts文件中發佈的內容嗎?我只是試了一下,而store.localhost的作品,我得到了404的其他東西。 – Griffin

+0

沒關係,我似乎已經得到它的工作。我只是將servername localhost塊指向www目錄。謝謝你的幫助 :) – Griffin