开发者

Virtual Host from Apache is different domain/directory but only use first

开发者 https://www.devze.com 2023-04-13 05:21 出处:网络
I\'ve configured two virtual host cuckoo.net and fb.core.net are located to local ip address (127.0.0.1)

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"
开发者_Go百科    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>


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>


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> 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号