VirtualHost examples in Apache

If you are setting new website and using apache web server, you can use following example for creating Virtual hosts.

Running several name-based web sites on a single IP address.

# Ensure that Apache listens on port 80
Listen 80
<VirtualHost *:80>
    DocumentRoot "/www/example1"
    ServerName www.example.com

    # Other directives here
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/www/example2"
    ServerName www.example.org

    # Other directives here
</VirtualHost>