Configuring multiple sites in apache

  apache, php, windows

I use Win10, Apache2.4 and PHP7.4. I created 2 test sites inside Apache24htdocs – Test.com and Test2.com, both containing simple index.php files. Here are exceptions from config files:

hosts:

    127.0.0.1 Test.com  www.Test.com
    127.0.0.1 Test2.com www.Test2.com

httpd.conf:

    # PHP7 module
    PHPIniDir "C:/Dev/PHP-7.4.24"
    LoadModule php7_module "C:/Dev/PHP-7.4.24/php7apache2_4.dll"
    AddType application/x-httpd-php .php

httpd-vhosts.conf:

    <VirtualHost _default_:80>
        DocumentRoot "${SRVROOT}/htdocs"
        ServerName www.example.com:80
    </VirtualHost>

    <VirtualHost *:80>
        DocumentRoot "${SRVROOT}/htdocs/Test.com"
        ServerName Test.com
        ServerAlias www.Test.com
    </VirtualHost>

    <VirtualHost *:80>
        DocumentRoot "${SRVROOT}/htdocs/Test2.com"
        ServerName Test2.com
        ServerAlias www.Test2.com
    </VirtualHost>

When loading both test.com and test2.com, browser shows folder index of htdocs. Only clicking on either index shows actual site, and browser address field become, for example, http://test.com/Test.com/. How to configure apache to show site from address like test.com?

Source: Windows Questions

LEAVE A COMMENT