Apache Pan Domain Name resolution

Source: Internet
Author: User

<virtualhost *:80>
DocumentRoot "E:\work\phpStudy\WWW\ncpx\web"
ServerName ncpxceshi2.com # # #主机名
Serveralias *.ncpxceshi2.com # # #范解析
<directory "/" >
Options FollowSymLinks execcgi
AllowOverride All
Order Allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>

DNS resolution can be added a.ncpxceshi2.com c.ncpxceshi2.com and so on level two domain name

Use: pseudo-static rewrite domain names such as sport.shop.com enter the movement of the page book.shop.com into the book page

==============================================================================

Requirements: Configure two items on Apache, Project A and project b,a.baiye5.com to Access project A, and the rest to project B, such as b2b.baiye5.com, *.baiye5.com, and so on, except for the a prefix.

First add Namevirtualhost *:80 in conf/httpd.conf


Under Apache directory conf create a new folder mysiteconf, and then creating a configuration file, such as baiye5.com.conf, open the file first configure the A.baiye5.com project A, and then configure item B, Because Apache will perform the configuration of the two virtual machines in order, if Project B is configured first, then project a will not be accessible, and if a.baiye5.com, perform the above virtual machine configuration first, then enter Project B.

The following are specific configurations

<virtualhost *:80>
ServerName a.baiye5.com
documentroot/var/www/html/Item A
<directory/var/www/html/Project A>
AllowOverride All
Options-multiviews
</Directory>
</VirtualHost>

<virtualhost *:80>
ServerName b2b.baiye5.com
Serveralias *.baiye5.com
documentroot/var/www/html/Item B
<directory/var/www/html/Project B>
AllowOverride All
Options-multiviews
</Directory>
</VirtualHost>

Explain:

Why should I configure it to conf/mysiteconf/?
In fact the real configuration file is conf/httpd.conf file, insert a sentence in the file include conf/mysiteconf/*.conf, the meaning of this sentence when loading all conf/mysiteconf/directories under the Conf suffix file, The purpose of this is to make Apache configuration more concise, in other words, users can also directly configure the above information within the conf/httpd.conf


ServerName: Domain name, wildcard characters not supported *
DocumentRoot: Project root directory (if Rails project is assigned to public directory)
Serveralias: Set the name of the virtual host, support the wildcard *, where the access to the universal domain name is supported
Namevirtualhost *:80 to be consistent with VirtualHost *:80, as follows

Namevirtual ... (IP or domain name)
<virtualhost ... (IP or domain name, and be absolutely consistent with the above) >
....
</VirtualHost>

Apache Pan Domain Name resolution

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.