虚拟主机的问题 apache 在 Windows - 请解释

这个问题从未发生过早。 (我多次尝试过), 但这一次

文件中定义的所有虚拟主机 virtual-hosts.conf 在安装目录中 apache, 在目录中发送浏览器 documentRoot 服务器 apache.

我用 Windows 7 使用最后一个版本 apache.

这些是定义的虚拟主机

NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <virtualhost> block.
#
<virtualhost *:80="">
ServerName dev.a.local
ServerAlias dev.a.local
DocumentRoot "D:/wwwroot/a/public"
ErrorLog "logs/a.log"
CustomLog "logs/a-access.log" common

<directory "d:="" a="" public"="" wwwroot="">
Options Indexes FollowSymLinks
AllowOverride All
# Controls who can get stuff from this server.
Order allow,deny
Allow from all
DirectoryIndex index.php
</directory>
</virtualhost>
<virtualhost *:80="">
ServerName dev.b.local
ServerAlias dev.b.local
DocumentRoot "D:/wwwroot/b/public"
ErrorLog "logs/b.log"
CustomLog "logs/b-access.log" common

<directory "d:="" b="" public"s="" wwwroot="">
Options Indexes FollowSymLinks
AllowOverride All
# Controls who can get stuff from this server.
Order allow,deny
Allow from all
DirectoryIndex index.php
</directory>
</virtualhost>

我改变了文件 hosts 和补充

127.0.0.1 dev.a.local 
127.0.0.1 dev.b.local

当我试图访问 dev.a.local 或者 dev.b.local, 我被n重定向。 documentRoot apache, 定义 httpd.conf.

请帮忙。
</virtualhost>
已邀请:

快网

赞同来自:

您确定的文件

<virtualhost>

块不包含在您的配置中。 (如果服务配置未在其命令行中定义配置路径 - 在捕捉中检查它 MMC 服务).

如果您发布的内容是文件的全部内容,则可以直接从您的主要配置安全启用它。

Include /path/to/virtual-hosts.conf

或者如果

virtual-hosts.conf

该文件包含所有基本服务器设置,如您的主要配置文件中,然后它可以设计为当前主要配置文件的替代品?

另一个变体 - 只需配置配置 vhosts 在主配置文件中而不是配置文件 virtualhosts, 他们目前你有。
</virtualhost>

江南孤鹜

赞同来自:

我从未见过几个

  <virtualhost *:80="">

更早的记录,如果它真正分割流量,则会非常惊讶。 另外,安装 serverAlias 与服务器名称相同的是肯定是冗余的。 而且您的示例不会显示配置 serverRoot (我希望她与众不同 documentRoot, 否则你会有很大的问题). 尝试:

NameVirtualHost *:80

<virtualhost dev.a.local="">
DocumentRoot "D:/wwwroot/a/public"
ErrorLog "logs/a.log"
CustomLog "logs/a-access.log" common

<directory "d:="" a="" public"="" wwwroot="">
Options Indexes FollowSymLinks
AllowOverride All
# Controls who can get stuff from this server.
Order allow,deny
Allow from all
DirectoryIndex index.php
</directory>
</virtualhost>
<virtualhost dev.b.local="">
DocumentRoot "D:/wwwroot/b/public"
ErrorLog "logs/b.log"
CustomLog "logs/b-access.log" common

<directory "d:="" b="" public"="" wwwroot="">
Options Indexes FollowSymLinks
AllowOverride All
# Controls who can get stuff from this server.
Order allow,deny
Allow from all
DirectoryIndex index.php
</directory>
</virtualhost>

</virtualhost>

要回复问题请先登录注册