Configuration of Apache second-level domain names

Source: Internet
Author: User

How to implement Apache second-level domain names

First, you have a top-level domain name with wildcard domain name resolution, for example, domain.com. Second, open mod_rewrite in httpd. conf
Add the following content at the end of httpd. conf:
RewriteEngine on
RewriteMap lowercase int: tolower
RewriteMap vhost txt:/usr/local/etc/apache/vhost. map
RewriteCond $ {lowercase: % {SERVER_NAME} ^ (. +) $
RewriteCond $ {vhost: % 1} ^ (/. *) $
RewriteRule ^/(. *) $ % 1/$1Here,/usr/local/etc/apache is the path of your apache server configuration file, which is changed according to the actual situation.
Then, create a file: vhost. map in the directory of the path.
Content:
Www.domain.com/usr/local/www/data-dist/domain
Bbs.domain.com/usr/local/www/data-dist/bbs
Anyname.domain.com/usr/local/www/data-dist/anynameThe above sections are in the form of "domain name + space + absolute path.
Finally, under your website root directory/usr/local/www/data-dist, create the corresponding directory:
Domain, bbs, anyname, etc., theoretically unlimited.
In this way, when accessing www.111cn.net through a browser, the files in the/usr/local/www/data-dist/domain directory are actually accessed. Similarly, accessing bbs.domain.com actually accesses files in the/usr/local/www/data-dist/bbs directory. And you can
Change vhost. map at any time to add, delete, and modify your second-level domain name and the actual path to. You do not need to restart apache.

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.