When we developed in the local, usually in the browser input http://localhost/project folder name to test the Web page file, have you ever thought of local in the browser to enter your own set of a domain name into the project folder, Configuring multi-domain names locally can test level two domain names and other domain-related issues.
For example, I would like to configure a primary domain name www.test.com and level two domain name img.test.com (in fact, two level domain name and configure another independent domain name principle is the same) first step: Open the Local System installation directory, such as I installed the Windows7, installed in the C drive, enter the directory \ Windows\system32\drivers\etc find a file called hosts, open with Notepad: Add the following code at the end of the file:127.0.0.1 www.test.com
127.0.0.1 www.test.com 127.0.0.1localhostsave when the input is complete. The second step: Open Apache installation location, as I am using Wampserver, the installation directory is: D:\wamp\bin\apache\Apache2.2.21Open a folder called Conf, which is the Apache configuration folderopen a file called httpd.confSearch for directory and find one such as:<directory "d:/wamp/www/" >the line, seeput code: Orderdeny,allowdeny from allAllow from 127.0.0.1Change to:Orderallow,deny allow from all Step three: In this httpd.conf file, search for includeconf/extra/httpd-vhosts.confremove the # in front of it and save the fileFourth Step: Open conf This folder next subdirectory: Extra, find a httpd-vhosts.conf This file, usually the last file,at the end of the file add:
<VirtualHost*:80>
DocumentRoot "D:/wamp/www/test"
ServerName www.test.com
</VirtualHost>
<VirtualHost*:80>
DocumentRoot "D:/wamp/www/test/img"
ServerName img.test.com
</VirtualHost>
<VirtualHost*:80>
DocumentRoot "d:/wamp/www/"
ServerName localhost
</VirtualHost>
this according to the directory according to their own Apache file directory to adjust, my Apache working directory for d:/wamp/www/, change to your Apache working directory.
The last step, restart Apache, enter in the browser: www.test.com will appear the default contents of the Test folder
(In Vhost, this opens the localhost)
<virtualhost *:80>
DocumentRoot "E:\wamp64\www"
ServerName localhost
</VirtualHost>
Apache Local configuration Multi domain name (wampserver local configuration multi-domain name)