First ensure you have set the type of your VM network as "Shared Network" (in Parallels open the VM Configure window > Hardware > Network). Don't know if it works with another network type.
From Parallels: browser test your OS X localhost:
Parallels creates a little DHCP network for your virtual machines, and the OS X machine itself is at the gateway IP. Go into Parallels > Preferences > Advanced > Network and the gateway is most likely the Start Address with a 0, 1 or 2 in front of it. For example, my Start Address is 10.211.55.1
and in Internet Explorer I type http://10.211.55.2
to hit the webserver I have running on OS X at http://localhost:80
.
So, go to your guest OS (Windows) and edit the hosts
file (on Windows it's located at C:\Windows\system32\drivers\etc\hosts
) to enter this Parallels gateway IP (in my case 10.211.55.2
) and name of the VirtualHost you've configured in Apache:
10.211.55.2 myvirtualhostname.localhost
10.211.55.2 myvirtualhostname2.localhost
This does the trick as that IP address is going to be maintained by Parallels and will not change as you change your location.
Now you can access to myvirtualhostname.localhost
(or whatever your VirtualHost is named on Apache) from guest's browser.