Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>
like image 236
vietean Avatar asked Feb 23 '23 16:02

vietean


1 Answers

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>
like image 182
Book Of Zeus Avatar answered Feb 25 '23 08:02

Book Of Zeus