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.
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.
In my httpd.conf file (the relevant parts, anyway...):
#
# 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.
#
<Directory "/Applications/MAMP/htdocs">
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/site1/"
ServerName site1.localhost.com
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/sub/site2/"
ServerName site2.localhost.com
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/sub/site3/"
ServerName site3.localhost.com
</VirtualHost>
In my /etc/hosts file:
##
# 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
In your httpd.conf file find the following line and remove the comment (#):
# NameVirtualHost *
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With