Virtual hosting with IIS / PWS using a single web-site

NOTE: The technique described in this article is only necessary if you are using IIS (Microsoft Internet Information Services) or PWS (Microsoft Personal Web Server) on Windows 98, Windows Me, NT4 Workstation, Windows 2000 Professional, or Windows XP - because IIS/PWS on these Windows versions are limited to a single web-site.
The versions of IIS for Windows Server and Windows Vista do not have this limitation (see reference article below).

"Virtual hosting" means hosting multiple web-sites with different domain names on the same IP address.

It is possible to simulate virtual hosting by redirecting HTTP requests through ASP script.

For example let say you have 3 domain names (dom1.com, dom2.com and dom3.com) and want to host a different web-site for each one.

First, in the web server root directory, create a sub-directory for each site.
For example:

c:\inetpub\wwwroot\dom1
c:\inetpub\wwwroot\dom2
c:\inetpub\wwwroot\dom3

Place all the html, image, asp, etc. files for each web-site in the appropriate sub-directory.

Next in the web server root directory, create a default asp file
c:\inetpub\wwwroot\default.asp

- with the following script code:

<%
Select Case Request.ServerVariables("HTTP_HOST")
Case "dom1.com", "www.dom1.com"
Response.Redirect "http://www.dom1.com/dom1"
Case "dom2.com", "www.dom2.com"
Response.Redirect "http://www.dom2.com/dom2"
Case "dom3.com", "www.dom3.com"
Response.Redirect "http://www.dom3.com/dom3"
End Select
%>

Modify the directory names and script code to match your domain names.
You should also add script code for error checking etc.

Each incoming HTTP request will now be redirected to the appropriate sub-directory.

In Simple DNS Plus, you configure each domain exactly the same - pointing to the same web-server IP address.

REFERENCES:
For more information, please see the following knowledge base articles:

KB Article Virtual hosting with IIS (Internet Information Services)
KB Article Can I use Simple DNS Plus to make my web-server access different directories / files on my computer for different domain names? (Sometimes referred to as "virtual hosting")

Add Feedback