Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local virtual hosts pointing to the same directory

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 [email protected]
  DocumentRoot "/Users/usr/Sites/Site1Name“
  ServerName local1.sitename.com
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot "/Users/usr/Sites/Site2Name“
  ServerName local2.sitename.com
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin [email protected]
  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

like image 872
HGB Avatar asked Feb 04 '14 16:02

HGB


1 Answers

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.

like image 179
HGB Avatar answered Oct 12 '22 21:10

HGB