Local virtual hosts pointing to the same directory

蹲街弑〆低调 提交于 2019-12-23 13:24:47

问题


I have been getting lost amidst forum posts on this issue.

1) I have MAMP (not Pro) Installed

2) My Apache port is set to 8888

3) My Document Root in preferences is set-up to /Users/usr/Sites

I want to set-up multiple local subdomains i.e.

private/etc/hosts

127.0.0.1    local1.sitename.com
127.0.0.1    local2.sitename.com
127.0.0.1    local3.sitename.com

No that is where the problem arises. In the httpd-vhosts.conf I tried to set up the following:

<VirtualHost *:80>
  ServerAdmin admin@si1tename.com
  DocumentRoot "/Users/usr/Sites/Site1Name“
  ServerName local1.sitename.com
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin admin@site2name.com
  DocumentRoot "/Users/usr/Sites/Site2Name“
  ServerName local2.sitename.com
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin admin@site3name.com
  DocumentRoot "/Users/usr/Sites/Site3Name“
  ServerName local3.sitename.com
</VirtualHost>

etc.

For some reason all of these subdomains point to the same localhost:8888 document root directory. What am I doing wrong?

Thanks


回答1:


I fixed this issue somehow by simply typing the directive for my virtual hosts as follows"

<VirtualHost *:80>
    DocumentRoot /Users/usr/Sites/Site2Name/
    ServerName local.Site2Name
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot /Users/usr/Sites/Site3Name/
  ServerName local.Site3Name
</VirtualHost>

Don't ask me to explain why did this fix the problem though. If anyone knows the answer, let me know.



来源:https://stackoverflow.com/questions/21557996/local-virtual-hosts-pointing-to-the-same-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!