Many webmasters want to base on the main domain name, to establish a number of subdomains, such as the main domain name is www.abc.com, want to add bbs.abc.com or blog.abc.com, let the sub-domain to the space of a certain level two directory such as bbs.abc.com corresponding Www.abc.com/bbs, is this a technique you want to learn? Some advanced virtual space and VPS can be configured through the background to achieve, for small space This How to break it? Listen to Uncle Tao to tell you ~
First step: space-bound sub-domain
In the space background, the binding domain name of the panel, you want to add the sub-domain name, such as Bbs.abc.com
Step Two: Domain name resolution:
To the domain manager of the background, your sub-domain name, as a CNAME or a record, resolved to the same as the primary domain address (a record corresponds to an IP address, the CNAME corresponds to a URL)
Step three: Add or modify the. htaccess file (for Linux hosts only, the Windows Host configuration method comes back separately)
In the. htaccess file, add the following nodes and modify them as you like.
# Open function
Rewriteengine on
#先作一个301, the domain name without www, go to the domain name with www (this must be written in front, otherwise it will be covered by the following sub-domain rules)
Rewritecond%{http_host} ^abc.com$
Rewriterule ^ (. *) $ http://www.abc.com/$1 [r=301,l]
#子域名设置正式开始
#把abc. com to your domain name, change BBS into your subdomain, and replace bbs/with your level two directory.
Rewritecond%{http_host} ^ (bbs.)? abc.com$
Rewritecond%{request_uri}!^/bbs/
Rewritecond%{request_filename}!-f
Rewritecond%{request_filename}!-d
Rewriterule ^ (. *) $/bbs/$1
Rewritecond%{http_host} ^ (bbs.)? abc.com$
Rewriterule ^ (/)? $ bbs/index.php [L]
#子域名设置结束
After writing, upload the. htaccess file to the root of the Web site.
If you support Uncle Tao, Welcome to join Uncle Tao's game VIP Exchange Group Oh ~ ~
Translated from "Uncle Tao Blog": http://game.jiuyuango.com/post/14.html
"Uncle Tao's unique building techniques" use the. htaccess file to implement the sub-domain mapping level two directory