Local virtual hosts pointing to the same directory

I am lost among forum posts on this issue.

1) I have MAMP installed (not Pro)

2) My Apache port is set to 8888

3) My document root in the settings is configured to / Users / usr / Sites

I want to configure several local subdomains ie

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, this is a problem. In httpd-vhosts.conf, I tried to configure 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 directory: 8888. What am I doing wrong?

thanks

+4
source share
1 answer

I somehow fixed this problem 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>

, . - , .

+1

Source: https://habr.com/ru/post/1525269/


All Articles