0
votes

I want to serve more than one host name on a server on a specific port. Let's say namely;

example1.com, example2.com, example3.com, example4.com.

I have configured them as;

<VirtualHost example1.com:85>
    ServerName www.example1.com
    ServerAlias www.example1.com example1.com
    .
    .
    .
</VirtualHost>
<VirtualHost example2.com:85>
    ServerName www.example2.com
    ServerAlias www.example2.com example2.com
    .
    .
    .
</VirtualHost>
<VirtualHost example3.com:85>
    ServerName www.example3.com
    ServerAlias www.example3.com example3.com
    .
    .
    .
</VirtualHost>
<VirtualHost example4.com:85>
    ServerName www.example4.com
    ServerAlias www.example4.com example4.com
    .
    .
    .
</VirtualHost>

When I use this configuration, it recommands me to use NameVirtualHost and all sites goes to first one.

When I add NameVirtulHost to each one it says www.example2.com, www.example3.com and www.example4.com has no virtualhosts. And first one goes to correct one but the others goes to second one.

How can I do this configuration properly.

1
You only need one NameVirutalHost - NameVirtualHost *:80 in your main config should do the trick - arco444
Can you be more spesific please? What exactly should I do? I am really very beginner about this issue :) - xxlali
You said: When I add NameVirtulHost to each one I said: You only need one NameVirutalHost I can't be much clearer! Look at the example here - arco444

1 Answers

0
votes

Generally, you only need each virtualhost to have the argument *:80, one NameVirtualHost *:80, then ServerAlias/ServerName in each VirtualHost. Using a hostname in virtualhost causes all sorts of trouble.