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 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)

Related Article

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.