title: MAC OS X: MAMP Environment & Virtual Hosts
body: <p>I'm not sure what's happening here, but I'm running MAMP 1.9 on MAC OS X.  In my httpd.conf file, the DocumentRoot is set to the default htdocs path.  Within the htdocs folder, I've created a number of "subsites" in an effort to set them up as Virtual Hosts.... I can get to the paths specified, but they all seem to default to the first one I set up.  </p>
  
  <p>Essentially, the first VirtualHost I configured was for site1.localhost.com.  I've since configured site2.localhost.com and site3.localhost.com.  However, going to either of the last two addresses, always seems to redirect me to site1.localhost.com.  Additionally, going to just localhost.com:8888 also just pulls up site1.localhost.com.  I'm not sure where I made a mis-step, but hopefully someone here will be able to help me figure out the problem... Oh, and I have restarted apache etc., after any changes made to either the /etc/hosts or httpd.conf file.  </p>
  
  <p>In my httpd.conf file (the relevant parts, anyway...):</p>
  
  <pre><code>#                                                                                                                                                                                                                                                                             
  # DocumentRoot: The directory out of which you will serve your                                                                                                                                                                                                                
  # documents. By default, all requests are taken from this directory, but                                                                                                                                                                                                      
  # symbolic links and aliases may be used to point to other locations.                                                                                                                                                                                                         
  #                                                                                                                                                                                                                                                                             
  # MAMP DOCUMENT_ROOT !! Don't remove this line !!                                                                                                                                                                                                                             
  
  
   DocumentRoot "/Applications/MAMP/htdocs"
  
  #                                                                                                                                                                                                                                                                             
  # Note that from this point forward you must specifically allow                                                                                                                                                                                                               
  # particular features to be enabled - so if something's not working as                                                                                                                                                                                                        
  # you might expect, make sure that you have specifically enabled it                                                                                                                                                                                                           
  # below.                                                                                                                                                                                                                                                                      
  #                                                                                                                                                                                                                                                                             
  
  #                                                                                                                                                                                                                                                                             
  # This should be changed to whatever you set DocumentRoot to.                                                                                                                                                                                                                 
  #                                                                                                                                                                                                                                                                             
  &lt;Directory "/Applications/MAMP/htdocs"&gt;
  
  &lt;VirtualHost *&gt;
  DocumentRoot "/Applications/MAMP/htdocs/site1/"
  ServerName site1.localhost.com
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *&gt;
  DocumentRoot "/Applications/MAMP/htdocs/sub/site2/"
  ServerName site2.localhost.com
  &lt;/VirtualHost&gt;
  
  &lt;VirtualHost *&gt;
  DocumentRoot "/Applications/MAMP/htdocs/sub/site3/"
  ServerName site3.localhost.com
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>In my /etc/hosts file:</p>
  
  <pre><code>##                                                                                                                                                                                                                                                                            
  # Host Database                                                                                                                                                                                                                                                               
  #                                                                                                                                                                                                                                                                             
  # localhost is used to configure the loopback interface                                                                                                                                                                                                                       
  # when the system is booting.  Do not change this entry.                                                                                                                                                                                                                      
  ##                                                                                                                                                                                                                                                                            
  127.0.0.1       localhost
  127.0.0.1       site1.localhost.com
  127.0.0.1       site2.localhost.com
  127.0.0.1       site3.localhost.com
  255.255.255.255 broadcasthost
  ::1             localhost
  fe80::1%lo0     localhost
  </code></pre>