The CP console in a virtual host does not support the ability to bind a two-level domain name to a subdirectory, and the user can bind a two-level domain name to a subdirectory through a program implementation.
There are two ways to bind a two-level domain name to a subdirectory:
1. Configure. htaccess, implemented by pseudo-static code. Specific implementation method reference: Http://help.aliyun.com/knowledge_detail/6554929.html?spm=5176.7114037.1996646101.1.SkYPg8&pos=1
Virtual host and Light cloud host implement sub-directory binding function by pseudo-static
WAN Network virtual host, light cloud host does not support through the console cp.hichina.com settings to point the domain name to the site subdirectory. However, this effect can be achieved by setting pseudo-static rules in the. htaccess configuration file:
For example, to implement access bbs.example.com when jumping to the example.com/bbs/directory,
You can create a. htaccess file under the/htdocs folder and write the following code in the. htaccess file
Rewritecond%{http_host} ^bbs.example.com [NC]
Rewriterule ^ (. *) $ http://example.com/bbs/$1 [l,r=301]
Note: The above method is only applicable to Linux hosts
2. Through the PHP program, the following procedures can be implemented:
<?php
Switch ($_server["Http_host"])
{
Case "a.test.cn": Header ("location:a/");
Break
Case "b.test.cn": Header ("location:b/");
Break
Case "c.test.cn": Header ("location:c/");
Break
}
?>
In the example above, the domain name is test.cn and the program means:
Access to the a.test.cn, will jump to htdocs a directory;
Access to the b.test.cn, will jump to htdocs B directory;
Access to the c.test.cn, will jump to htdocs C directory;
When doing a domain name resolution, you need to resolve the a.test.cn,b.test.cn,c.test.cn to the IP address of the virtual host.
Thus the function of the two-level domain name Binding subdirectory is implemented in the program.
Linux virtual host through the program implementation of the two-level domain binding to subdirectories