2012-03-12 177 views
1

OS:WinXP的本地主機重定向到虛擬主機

服務器:XAMPP(Apache)的

使用Zend CLI工具創建一個空的項目後,我加入了虛擬主機建議部分我的httpd-vhosts.conf和將項目名稱添加到主機文件。我的項目的快速入門頁面顯示正常。但是,現在路徑'localhost'呈現項目頁面,而不是正常的xmapp主頁。

這並不能阻止我工作,而且如果有的話,我也不會使用xampp主頁。但我擔心,如果我將來增加更多的虛擬角色,將會有衝突。

根據其他一些相關帖子,我取消了註釋NameVirtualHost行。但它似乎沒有工作。然後我嘗試以下每個但無濟於事:

  • 了NameVirtualHost *
  • 了NameVirtualHost本地主機:80
  • 了NameVirtualHost *:80

的httpd-vhosts.conf

NameVirtualHost localhost 

<VirtualHost *:80> 
    DocumentRoot "C:/xampp/htdocs/cv/public" 
    ServerName .local 

    # This should be omitted in the production environment 
    SetEnv APPLICATION_ENV development 

    <Directory "C:/xampp/htdocs/cv/public"> 
     Options Indexes MultiViews FollowSymLinks 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 

</VirtualHost> 

hosts

127.0.0.1  localhost 
127.0.0.1  cv 

回答

1

通過閱讀,.local似乎是你的問題。

# Setup "helloworld" Virtual Host 
<VirtualHost *:80> 
ServerName helloworld.tld 
DocumentRoot "C:\projects\helloworld\public" 

    <Directory "C:\projects\helloworld\public"> 
     Options Indexes FollowSymLinks Includes 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

來源:http://survivethedeepend.com/zendframeworkbook/en/1.0/creating.a.local.domain.using.apache.virtual.hosts#zfbook.creating.a.local.domain.using.apache.virtual.hosts.configuring.local.hosts.file

+0

http://httpd.apache.org/docs/2.0/vhosts/name-based.html – Jake 2012-03-12 23:11:49

+0

http://httpd.apache.org/docs/2.0/vhosts/examples.html – Jake 2012-03-12 23:12:32

+0

謝謝。該鏈接特別有用。它肯定會出現在我的書籤中。 – dsulli 2012-03-12 23:32:39

1

要使用URL訪問該站點http://cv/你必須改變ServerName指令。爲了保持乾淨,請使用如下格式:http://*.local.net/

還要確保如果您使用的是代理服務器,請將該模式添加爲您的瀏覽器的例外情況。

NameVirtualHost localhost 

<VirtualHost *:80> 
    DocumentRoot "C:/xampp/htdocs/cv/public" 
    ServerName cv.local.net 

    # This should be omitted in the production environment 
    SetEnv APPLICATION_ENV development 

    <Directory "C:/xampp/htdocs/cv/public"> 
     Options Indexes MultiViews FollowSymLinks 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 

</VirtualHost>