Yeap, VirtualHosts are the answer. Let me explain sorta how it works ....
When someone visits a domain name, a DNS server connects that domain name to an IP address and just as with any hosting company hosting many websites, there's often only a few IP addresses for all of the hundreds of domain names.
So what happens is that the web server (Apache)
detects what domain name brought them to that IP address and then routes the visitor to the correct content.
That routing is done within the virtual hosts files in Apache.
So here's what you need to do ....
- If the Apache documentation doesn't make sense regarding Virtual Hosts, http://httpd.apache.org/docs/2.4/vhosts/examples.html, find a good tutorial to help you get going. There's plenty of past discussions on this forum about it.
- Understand the ServerName directive in a VirtualHost is how Apache identifies the incoming domain request and directs it to the correct content. So say you have mydomain.com, your ServerName and ServerAlias will be something like:
- Code: Select all
The rest of the Virtual Host is in regards to directory permissions, error logging, etc.
It's not too complicated once you understand how a URL request works, at least the basic idea of it. Hope that helps.