MAC OS X: MAMP Environment & Virtual Hosts

只愿长相守 提交于 2019-12-03 15:04:45

In your httpd.conf file find the following line and remove the comment (#):

 # NameVirtualHost * 

In addition to MattLeff's answer, you should also add a server alias, just to be safe:

ServerAlias www.website.dev

If you don't and your browser automagically adds "http://www" (and hides it, rawr!) then your environment will automatically default to the first virtual host.

I can see you got your answer. It wasn't sufficient in my case. I was able to get the localhost + many other vhosts (demo.client.com) working on my MAMP when I added Chords's suggestion. It only worked when I added the localhost as a virtual host, on the top of the list.

NameVirtualHost *:80
<VirtualHost *:80>
  DocumentRoot "/Applications/MAMP/htdocs"
  ServerName localhost
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin me@email.com
  DocumentRoot "/Applications/MAMP/htdocs/clientA/"
  ServerName clientA.local
  ErrorLog "logs/clientA-local-error_log"
  CustomLog "logs/clientA-local-access_log" common
</VirtualHost>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!