I did not find a recent example in our Forum for doing this, so here is something I threw together -
Here is a working example using Apache virtual hosts on a Windows development system. This assumes existing Apache settings are the installation defaults for installing Apache directly using the Windows installer and Apache works for
http://localhost You will need to adapt your paths as needed for any other type of Apache installation.
The existing "localhost" will remain mapped to the existing folder (on my system this is) -
C:\Program Files\Apache Software Foundation\Apache2.2\htdocs
This example will add a "domain"
www.example1.com (and example1.com) that will be mapped to a folder -
C:\Program Files\Apache Software Foundation\Apache2.2\example1\htdocs
This could be to any folder. I picked one that starts in the Apache2.2 main folder.
Note: In all the following code blocks,
examplel is actually example1
Step 1:
Near the end of your httpd.conf, there is a line to include a httpd-vhosts.conf file -
Remove the # in front of the second line to cause httpd.conf to read the contents of conf/extra/httpd-vhosts.conf
Step 2:
In Windows, navigate to C:\Program Files\Apache Software Foundation\Apache2.2\conf\extra and make a copy of the existing httpd-vhosts.conf file.
Edit httpd-vhosts.conf to contain the following -
Step 3:
Find or create the file C:\WINDOWS\system32\drivers\etc\hosts
The hosts file should have the following lines to work with this example -
Step 4:
Stop and start your web server to get these changes to the .conf files to take effect.
Going to
http://localhost should get your existing web documents
Going to
http://example1.com or
http://www.example1.com should get your web documents in the new example1/htdocs folder.