I got a strange problem trying to define multiple virtual hosts in Apache. This is my code for httpd.conf file:
<VirtualHost *:8888>
ServerName site1.local
DocumentRoot /Applications/MAMP/htdocs/site1/public
<Directory /Applications/MAMP/htdocs/site1/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:8888>
ServerName site2.local
DocumentRoot /Applications/MAMP/htdocs/site2/public
<Directory /Applications/MAMP/htdocs/site2/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When I try to access "site2.local" in browser, I'm redirected to "site1.local". This will happen to all VirtualHost definitions that I insert below in the httpd.conf file. When I want to access "site2.local" or any other, I need to put its VirtualHost definition on the top (as the first one). So, I assume that Apache is only executing correctly the first VirtualHost.
Also, another problem: if I try to access any file of project in my htdocs folder which is not defined in VirtualHost, I will get a message "Forbidden, You don't have permission to access /project/ on this server." If I want to access any of these projects, I need to remove all VirtualHost definitions in httpd.conf file.
What I am doing wrong?
In my case, these (defined in VirtualHost) are PHP projects w/ Zend Framework. I'm using MacOSX.
Thank you