Setting up DNS Aliases​

You can create one or more directories for content within your web server’s file structure, but you can’t put them in any location on your machine. For example, most Apache server web files are located in the htdocs folder. Create a sub-folder there to host your domain files—perhaps within a www folder to segregate the content from other uses. It’s a good idea to put an index.html file in the directory so you can test later.

In version 1 of Apache, edit the apache.conf file and find the vhosts (virtual hosts) section.In version 2 of Apache, edit the vhosts.conf file. These configuration files are usually located in a configuration directory on your web server, not in the htdocs area.

In either version, edit the vhosts section to add a new virtual host.

Structure of a Virtual Host Entry

A typical use case involves running different hostnames that resolve to the same Internet Protocol address, and each hostname must respond differently. For example, internal.server.com may reference a company’s intranet site while www.server.com may reference its public-facing web page. To configure these examples, edit the virtual-host file as follows: For additional use cases for example virtual-host files, check out Apache’s documentation.

Reboot the Web Server

After completing your edits, reboot the web server, then test the new configuration.