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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lennartvddCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.