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 with the configuration of another separate domain name principle is the same)
The
first step: Open the Local system installation directory, such as I installed WINDOWS8, installed on the C drive, into the directory C:\Windows\System32\drivers\etc
Find a file called hosts and open it with Notepad:
Add the following code at the end of the file:
127.0.0.1 www.test.com127.0.0.1 www.test.com127.0.0.1 localhost
Save 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.21
Open a folder called Conf, which is the Apache configuration folder
Open a file called httpd.conf
Search for Directory and find one such as: <directory "d:/wamp/www/" >
Line, after seeing the code
Put the code:
Order Deny,allow deny from all to 127.0.0.1
Change to:
Order Allow,deny allow from all
Step Three:
In just this httpd.conf file, search for the include conf/extra/httpd-vhosts.conf
remove the # in front of it and save the file
Fourth 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>
According to the directory according to their own Apache file directory to adjust, my Apache working directory for d:/wamp/www/, changed to their Apache working directory.
The last step, restart Apache, enter in the browser: www.test.com will appear the default contents of the Test folder
Apache Local configuration Multi domain name (wampserver local configuration multi-domain name)