title: Point domain name to specific folder on server
body: <p>I am currently working on a CMS type of site where users can create websites on my server. </p>
  
  <p>I want to be able to create subdomains for the user's website for them to see the preview. </p>
  
  <p>The next step would be for users to be able to point their domain name to my server, and when users go to the domain it would go to their own designated folder on my server. </p>
  
  <p>How would I go about doing this automatically with php, I have been looking for solutions with no avail. </p>
  
  <p>I currently have a Virtual Server with hostgator. Please advise, or point me in the right direction. Any solutions are welcome as well, I am pretty much stuck at this point. </p>
  
  <p>Thank you very much. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>For example, if my domain is www.mydomain.com, when a user makes an account, the subdomain username.mydomain.com is created. Later down the line, if the user buys the domain name www.userdomain.com, I want to make it so that if www.userdomain.com is entered, it shows what is on www.mydomain.com/userdomain. The URL should still show www.userdomain.com</p>