WAMP Server: only working with first virtual host and 1 sub domain

Hi
I am in the process of moving 50 websites from IIS to WAMP
I am using Apache 2.0.58
I have created several virtual host in the httpd.com file and also in the host file

This is how it looks from the top:
-----------------------------------------------------------------------------------------------------------------
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
#     ServerAdmin webmaster@dummy-host.example.com
#     DocumentRoot /www/eadvice_demo
#     ServerName eadvice.dk
#     ErrorLog logs/eadvice.dk-error_log
#     CustomLog logs/eadvice.dk-access_log common
#</VirtualHost>



<VirtualHost *:80>
    ServerAdmin morten@e-advice.dk
    DocumentRoot "C:\wamp\www\eadvice_demo"
    ServerName eadvice.dk
    ErrorLog "logs/eadvice-error.log"
    CustomLog "logs/eadvice-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin NK25@tvind.dk
    DocumentRoot "C:\wamp\www\videos"
    ServerName pictures.nytaarskoncert-tvind.dk
    ErrorLog "logs/pictures-error.log"
    CustomLog "logs/pictures-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin morten@e-advice.dk
    DocumentRoot "C:\wamp\www\magleby"
    ServerName magleby.dk
    ErrorLog "logs/magleby-error.log"
    CustomLog "logs/magleby-access.log" common
</VirtualHost>

--------------------------------------------------------------------------------------------------------------------
Like this the www.eadvice.dk and the http://pictures.nytaarskoncert-tvind.dk WORKS OK

but www.magleby.dk shows the website for www.eadvice.dk

If i move www.magleby to the top of the virtual server list it will show magleby.dk even when i type www.eadvice.dk

Its like it will only display the first virtual host and virtual sub domain.

I hope someone can spot the error.  I am sure its basic but I am just stuck

Regards
Morten
morten444Asked:
Who is Participating?
 
lennartvddConnect With a Mentor Commented:
If you specify www. you're actually make a request to a subdomain of  your servername,which you need to specifically mention in your  virtualhosts configuration as a ServerAlias in order for Apache to map a  site to it.

The first virtual host will always be served as a default in case Apache can not map the given hostname to any of the ServerNames. Apache will not find www.eadvice.dk, but it will serve it to you because it's the first (defaul) virtual host.
pictures.nytaarskoncert-tvind.dk will work fine, because it's an exact match to the 2nd ServerName.

So you should also specify:
ServerAlias www.[domain].[tld]
to make that work.


<VirtualHost *:80>
ServerAdmin morten@e-advice.dk
DocumentRoot "C:\wamp\www\eadvice_demo"
ServerName eadvice.dk
ServerAlias www.eadvice.dk
ErrorLog "logs/eadvice-error.log"
CustomLog "logs/eadvice-access.log" common
</VirtualHost>


<VirtualHost *:80>
ServerAdmin NK25@tvind.dk
DocumentRoot "C:\wamp\www\videos"
ServerName pictures.nytaarskoncert-tvind.dk
ErrorLog "logs/pictures-error.log"
CustomLog "logs/pictures-access.log" common
</VirtualHost>


<VirtualHost *:80>
ServerAdmin morten@e-advice.dk
DocumentRoot "C:\wamp\www\magleby"
ServerName magleby.dk
ServerAlias www.magleby.dk
ErrorLog "logs/magleby-error.log"
CustomLog "logs/magleby-access.log" common
</VirtualHost>

Open in new window

0
 
rjdownCommented:
magleby.dk is not the same as www.magleby.dk, you need to define that as well.

Example:

<VirtualHost *:80>
    ServerAdmin morten@e-advice.dk
    DocumentRoot "C:\wamp\www\magleby"
    ServerName magleby.dk
    ServerAlias www.magleby.dk
    ErrorLog "logs/magleby-error.log"
    CustomLog "logs/magleby-access.log" common
</VirtualHost>
0
 
rjdownCommented:
Woops screwed that up with extra virtualhost tags, and got sniped anyway haha :D
0
 
morten444Author Commented:
Hi
Thanks. That resolved the problem

Thanks
0
 
lennartvddCommented:
sorry rjdown ;)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.