Apache 的虚拟主机是不同的域/目录,但仅首先使用

发布于 2024-12-09 22:09:35 字数 934 浏览 1 评论 0原文

我已经配置了两个虚拟主机 cuckoo.netfb.core.net 位于本地 IP 地址(127.0.0.1)

但是当我访问第二个域时: < code>fb.core.net,它总是返回第一个。

请考虑以下配置来帮助我,我真的不知道我在这里错了什么。

<VirtualHost *:80>
    DocumentRoot "d:/_iLearning/iCuckoo"
    ServerName cuckoo.net
    ServerAlias www.cuckoo.net
    SetEnv APPLICATION_ENV "development"
    <Directory d:/_iLearning/iCuckoo>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "d:/_Devs/fbcore/public"
    ServerName fb.core.net
    ServerAlias www.fb.core.net
    SetEnv APPLICATION_ENV "development"
    <Directory d:/_Devs/fbcore/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

I've configured two virtual host cuckoo.net and fb.core.net are located to local ip address (127.0.0.1)

But when I access the second domain: fb.core.net, it always returns the first.

Please consider the below configuration to help me, I really don't know what I am wrong here.

<VirtualHost *:80>
    DocumentRoot "d:/_iLearning/iCuckoo"
    ServerName cuckoo.net
    ServerAlias www.cuckoo.net
    SetEnv APPLICATION_ENV "development"
    <Directory d:/_iLearning/iCuckoo>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "d:/_Devs/fbcore/public"
    ServerName fb.core.net
    ServerAlias www.fb.core.net
    SetEnv APPLICATION_ENV "development"
    <Directory d:/_Devs/fbcore/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一个人练习一个人 2024-12-16 22:09:35

将 fb.core.net 添加到 ServerAlias

<VirtualHost *:80>
    DocumentRoot "d:/_Devs/fbcore/public"
    ServerName fb.core.net
    ServerAlias www.fb.core.net fb.core.net # you can add more than one here
    SetEnv APPLICATION_ENV "development"
    <Directory d:/_Devs/fbcore/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Add fb.core.net to the ServerAlias

<VirtualHost *:80>
    DocumentRoot "d:/_Devs/fbcore/public"
    ServerName fb.core.net
    ServerAlias www.fb.core.net fb.core.net # you can add more than one here
    SetEnv APPLICATION_ENV "development"
    <Directory d:/_Devs/fbcore/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
顾北清歌寒 2024-12-16 22:09:35

我今天面临这个问题
请检查这个网址
http://alexking.org/blog /2007/11/01/apache-2-only-serves-first-virtual-host

我添加的配置

NameVirtualHost *

我认为您需要添加

NameVirtualHost *:80

或更改


我的配置

NameVirtualHost *

<VirtualHost *>
    DocumentRoot /home/host1/www
    ServerName host1.bdwey.com
    ServerAlias www.host1.bdwey.com
    <Directory "/home/host1/www">
        allow from all
        Options +Indexes
    </Directory>
</VirtualHost>

<VirtualHost *>
    DocumentRoot /home/host2/www
    ServerName host2.bdwey.com
    ServerAlias www.host2.bdwey.com
    <Directory "/home/host2/www">
        allow from all
        Options +Indexes
    </Directory>
</VirtualHost> 

i face this issue today
please check this url
http://alexking.org/blog/2007/11/01/apache-2-only-serves-first-virtual-host

my config i add

NameVirtualHost *

i think you need to add

NameVirtualHost *:80

or change
<VirtualHost *:80>
to
<VirtualHost *>

My config

NameVirtualHost *

<VirtualHost *>
    DocumentRoot /home/host1/www
    ServerName host1.bdwey.com
    ServerAlias www.host1.bdwey.com
    <Directory "/home/host1/www">
        allow from all
        Options +Indexes
    </Directory>
</VirtualHost>

<VirtualHost *>
    DocumentRoot /home/host2/www
    ServerName host2.bdwey.com
    ServerAlias www.host2.bdwey.com
    <Directory "/home/host2/www">
        allow from all
        Options +Indexes
    </Directory>
</VirtualHost> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文