Forum Moderators: phranque
I'm having difficulty setting up two virtual hosts on my Mac server. My directives look like this (real IPs and addresses changed to protect the guilty) -
##############
NameVirtualHost 66.***.211.94:16080
<VirtualHost 66.***.211.94:16080>
ServerName example.com
DocumentRoot "/Users/example/sites"
</VirtualHost>
<VirtualHost 66.***.211.94:16080>
ServerName example2.com
DocumentRoot "/Users/example2/sites"
</VirtualHost>
###############
In this setup, all requests to both example.com and example2.com will be served from "/Users/example/sites"! And if I place example2.com's VirtualHost directive at the top, then both sites will be served from "/Users/example2/sites". Anyone have any idea how I can decouple the sites from each other?
Many thanks,
Chris
[edited by: jdMorgan at 5:54 pm (utc) on April 18, 2005]
[edit reason] Removed specifics per TOS. [/edit]
Are you accessing using 'example.com' and 'example2.com' or 'www.example.com' and 'www.example2.com'. ServerName is fairly specific; it has to match the hostname /exactly/. If you're trying to access using 'www.example.com', add a ServerAlias:
NameVirtualHost 192.168.1.1:16080
<VirtualHost 192.168.1.1:16080>
ServerName www.example.com
ServerAlias example.com
(...other directives here)
</VirtualHost>
<VirtualHost 192.168.1.1:16080>
ServerName www.example2.com
ServerAlias example2.com
(...other directives here)
</VirtualHost>
Other possibilities: