Apache Local configuration Multi domain name (wampserver local configuration multi-domain name)

Source: Internet
Author: User



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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.