Virtual Hosting or Virtual Directory Using IIS

This article explains how to create a Virtual Host or Virtual Directory on a single Virtual Machine using IIS. This post is helpful for website designers for creating multiple virtual hosts on a single IP or host server.

Virtual hosting is a process for hosting multiple domain names on a single server. This is basically sharing the services of a single server for multiple companies or for multiple websites. Sometimes it's called Vhost. A Virtual Host is ususally used by a company or organization that doesn't want to maintain or purchase multiple servers. Virtual Hosting can be supported using IIS Web Server or using Apache Web Server. In this blog we will see how to create a virtual host using IIS Web Server on Windows Server 2012 VM.

Virtual Hosting or Virtual Directory using IIS

  1. Install IIS on your server VM and restart it.

  2. Open IIS manager and browse to your site (or choose default site).

    IIS manager

  3. Select your web site and right-click the mouse and select “Add Virtual Directory“.

    Add Virtual Directory

  4. In this window set the alias name and physical path where your webpage is stored. Press the OK button so it will create a virtual directory. The alias name is the name to access this directory over the internet.

    For example with an alias of abc_alias we can access it using the following URL: www.domain.com/abc_alias/.

    Alias

  5. Now create the default webpage on that “Physical Path directory”, for example home.html, default.asp and abc.html. This default webpage must be added to the Default Document Set. So it can load when the virtual directory is hit over the internet.

    Physical Path directory

  6. Now add the default webpage entry into the “Default Document” of the current Virtual Directory. Open it by double-clicking on the Default Document Icon.

    Default Document

  7. Click Add from the top-right corner and add your default webpage name with extension.

    For example homepage.html.

    Click Add

  8. Now test your sub-domain in the web browser using IIS or with a URL.

    Syntax: Host_Name/Virtual_Directory_Name.

    For example testingadmin.cloudapp.net/subdomain.

    browser

  9. Use the same process for creating multiple Virtual Directories. As shown in the preceding image there are three Virtual Directories created that can be accessible using the following URLs.

    • www.domain.com/aaa/
    • www.domain.com/bbb/
    • www.domain.com/subdomain/

    three Virtual directory