w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Apache named-based VirtualHost configuration for multiple sites in one host

This has to be done through your http server configuration (like apache).

VirtualHosts is how you split multiple domains across one computer, and their respective .htaccess configuration will give you protection for your site (username/password).

If you just want to split the computer into multiple hosts, you don't need to use .htaccess.

See the following links
Here are some VirtualHost Configuration Examples
Apache HTTP Server Tutorial
Server Config Files

Excerpt from the "example's" link on "Name-Based Virtual Hosts":

    DocumentRoot /www/example1
    ServerName www.example.com

    # Other directives here ...

    DocumentRoot /www/example2
    ServerName www.example.org

    # Other directives here ...

The configuration file is usually located in /etc/apache2/apache2.conf which then reads from /etc/apache2/sites-enabled/*.conf which are essentially symbolic links to /etc/apache2/sites-available/*.conf - those files are used with the above code to accomplish the results you describe.

You may also be interested looking into nginx, an alternative to apache2.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.