2012-03-12 178 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>