How to Set up a DNS Alias With Apache
How to Set up a DNS Alias With Apache GA S REGULAR Menu Lifewire Tech for Humans Newsletter! Search Close GO Internet, Networking, & Security > Home Networking
Listen 80
DocumentRoot "/www/intranet"
ServerName internal.server.com
# Other directives here
DocumentRoot "/www/public"
ServerName www.server.com
# Other directives here For additional use cases for example virtual-host files, check out Apache's documentation.
How to Set up a DNS Alias With Apache
Serving multiple domains from an Apache web server
By Jennifer Kyrnin Jennifer Kyrnin Freelance Contributor University of California University of Washington Jennifer Kyrnin is a professional web developer who assists others in learning web design, HTML, CSS, and XML. lifewire's editorial guidelines Updated on June 25, 2021 Tweet Share Email Tweet Share Email Home Networking ISP The Wireless Connection Routers & Firewalls Network Hubs Broadband Ethernet Installing & Upgrading Wi-Fi & WirelessWhat to Know
Edit the apache.conf (version 1) or vhosts.conf (version 2) file, then find vhosts (virtual hosts) section. Edit as per below instructions.After completing your edits, reboot the web server, then test the new configuration. Set up DNS aliases with the Apache web server to point different hostnames to different directories on your web server.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. Setting DNS aliases on the web server doesn't change DNS settings. You must still configure your DNS to map an IP address to specific hostnames.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: # Ensure that Apache listens on port 80Listen 80
DocumentRoot "/www/intranet"
ServerName internal.server.com
# Other directives here
DocumentRoot "/www/public"
ServerName www.server.com
# Other directives here For additional use cases for example virtual-host files, check out Apache's documentation.