我已经阅读了许多帖子,并在同一IP地址上为2个站点配置了WAMP,如下所示(httpd.conf摘录):
#Tell Apache to identify which site by name
NameVirtualHost *:80
#Tell Apache to serve the default WAMP server page to "localhost"
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/wamp/www"
</VirtualHost>
#Tell Apache configuration for 1 site
<VirtualHost 127.0.0.1>
ServerName client1.localhost
DocumentRoot "C:/wamp/www_client1"
<Directory "C:/wamp/www_client1">
allow from all
order allow,deny
AllowOverride all
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
#Tell Apache configuration for 2 site
<VirtualHost 127.0.0.1>
ServerName client2.localhost
DocumentRoot "C:/wamp/www_client2"
<Directory "C:/wamp/www_client2">
allow from all
order allow,deny
AllowOverride all
</Directory>我还更改了Windows主机文件,以添加127.0.0.1、client1.localhost等。但是,当我重新启动WAMP服务时,//client1.localhost和//client2.localhost转到c:\wamp\www文件夹中的默认站点。
真的很感谢任何人的帮助。
发布于 2013-04-02 23:50:08
你在httpd.conf中包含你的vhosts.conf了吗?
取消注释httpd.conf底部附近的这一行(以‘Include’开头的那行):
# Virtual hosts - leave this commented
Include conf/extra/httpd-vhosts.conf编辑:看起来问题是NameVirtualHost和VirtualHost必须匹配,所以你不能同时使用NameVirtualHost *:80和VirtualHost 127.0.0.1。相反,可以使用NameVirtualHost *:80和VirtualHost *:80,或者使用NameVirtualHost 127.0.0.1:80和VirtualHost 127.0.0.1。
如果它们不匹配,您将看到您的评论中提到的行为,其中不匹配其他虚拟主机的虚拟主机将被命中,或者如果它们都相同,第一个虚拟主机(您的默认本地主机)将被命中。
有关更多信息,请参阅本文:Wamp Server: Multiple Virtual Hosts are not working on Windows
发布于 2013-04-27 09:17:01
试试这个配置,它只是你的几个小模块
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
## must be first so the the wamp menu page loads
<VirtualHost *:80>
ServerAdmin webmaster@homemail.net
DocumentRoot "C:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
</VirtualHost>
#Tell Apache configuration for 1 site
<VirtualHost *:80>
ServerName client1.localhost
DocumentRoot "C:/wamp/www_client1"
<Directory "C:/wamp/www_client1">
AllowOverride All
order Allow,Deny
Allow from all
</Directory>
DirectoryIndex index.html index.php
</VirtualHost>
#Tell Apache configuration for 2 site
<VirtualHost *:80>
ServerName client2.localhost
DocumentRoot "C:/wamp/www_client2"
<Directory "C:/wamp/www_client2">
AllowOverride All
order Allow,Deny
Allow from all
</Directory>https://stackoverflow.com/questions/15765160
复制相似问题