If we wish to host multiple sites on one server, we can do so with virtual hosting. Virtual hosting is a way to uniquely handle multiple domain names according to their name. The technique is surprisingly simple: we just look at the incoming
Host header and respond accordingly. In this task, we're going to implement simple name based virtual hosting for static sites.
We'll create a folder called
nodecookbook as subdirectories. In
localhost-site/index.html we'll write the following:
<b> This is localhost </b>
nodecookbook/index.html we'll add the following code:
<h1>Welcome to the Node Cookbook Site!</h1>
For local testing, we'll want to configure our system ...