Apache virtual directory enables multiple domain names to be bound to the same IP

Source: Internet
Author: User
Tags aliases

Before: I'm using XAMPP, so the path may be different

Find apache\conf\extra\httpd-vhosts.conf , if not, please create a new httpd-vhosts.conf file yourself, and in the httpd.confInclude conf/extra/httpd-vhosts.conf

Namevirtualhost*:80# # If there is no matching servername then the first configuration is selected by default<virtualhost*:80>DocumentRoot"d:/apps/xampp/htdocs/"ServerNamelocalhost    # #ErrorLog "Logs/dummy-host2.example.com-error.log"    # #CustomLog "Logs/dummy-host2.example.com-access.log" Common</VirtualHost><virtualhost*:80>ServerAdmin[email protected]DocumentRoot"D:/apps/xampp/htdocs/www/cdn"ServerNamecdn.demo.comServeraliascdn.test.com    # #ErrorLog "Logs/cdn.demo.com.com-error.log"    # #CustomLog "Logs/cdn.demo.com.com-access.log" Common</VirtualHost><virtualhost*:80>ServerAdmin[email protected]DocumentRoot"D:/apps/xampp/htdocs/www/admin"ServerNameadmin.demo.comServeraliasadmin.test.com    # #ErrorLog "Logs/admin.demo.com-error.log"    # #CustomLog "Logs/admin.demo.com-access.log" Common</VirtualHost>

Modify the host file cdn.demo.com and admin.demo.com point to127.0.0.1

After rebooting, we can access the cdn.demo.com CDN folder under the Apache directory, as well as admin.demo.com access the Admin folder.

admin.demo.comAnd cdn.demo.com can be different domain names

Note in the httpd-vhosts.conf
The first VirtualHost配置 priority is the highest, and if the requested address VirtualHost配置 is not found in the other, the default point is to the first, which is often referred to as主服务器

VirtualHost *:80 Monitor Any 80-port access

VirtualHost * Listen to any address

VirtualHost 127.0.0.1:80 only listens on 127.0.0.1: Access

VirtualHost can be followed by multiple URLs, separated by a space

ServerAdmin Administrator contact can be ignored when address access errors are now on the page

ServerName the domain name that is mapped to

Serveralias aliases, such as the above, cdn.test.com can be accessed through aliases cdn.demo.com

DocumentRoot mapping directory, which is the address where the file exists, may cause Apache to fail if the mapping directory does not exist

For additional information including agents, directory permissions and more, please refer to the official documentation

Apache virtual directory enables multiple domain names to be bound to the same IP

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.