Simple VirtualHost ServerName question
Is "ServerName" what distinguishes requests from each other?
Say I had three domains, domain1.com, domain2.com, and domain3.com. They are all set up with DNS to point to my node's IP address.
I should then, create three VirtualHost entries, with ServerName corresponding respectively to each, and specifying separate directories.
But just to make sure, "ServerName" is what determines where each domain goes, even if they're all pointing to the same ip?
For example, I go to example1.com in my browser. Apache loads the VirtualHost who's servername is "
2 Replies
@sam-the-man:
When creating virtual hosts,
Is "ServerName" what distinguishes requests from each other?
Say I had three domains, domain1.com, domain2.com, and domain3.com. They are all set up with DNS to point to my node's IP address.
I should then, create three VirtualHost entries, with ServerName corresponding respectively to each, and specifying separate directories.
But just to make sure, "ServerName" is what determines where each domain goes, even if they're all pointing to the same ip?
For example, I go to example1.com in my browser. Apache loads the VirtualHost who's servername is "
www.example1.com " and shows that corresponding directory in the browser?
Yes, ServerName (as well as ServerAlias) are used for matching the client's Host-header when using name-based virtual hosts.
See http://httpd.apache.org/docs/2.2/vhosts/name-based.html
Here are some other guides and documentation: