After registering the domain name, often needs to realize different two level domain name to visit the different node of the site
The general domain name registers the organization to provide the CNAME the analytic way, may the two level domain name define to the different IP.
Like what
Www.abc.com point to primary node 1.2.3.4
Bbs.abc.com point to 1.2.3.4/bbs or another IP but if you rent a hosting space, the problem of egg aches is coming.
Web site has only one IP, and the site is rented hosting space, not managed host, can not directly set different access nodes, managed space can only set up a space provider to provide a portal URL
That is, the site has only one portal, the level two domain name can not be directly resolved to different subdirectories
Using PHP's code can solve this problem,
Ideas
1. Define different level two domain name, point to the same website portal
2. In the first page of the portal index.php, judge the user entered the domain name, and then redirect to the site sub-contact
PHP global variable $_server[' http_host ', you can get the user's current access to the domain name string, in which to query their own definition of each child domain name string, and then use the header function to redirect to different pages
The code is as follows
if (Strpos ($_server[' http_host '), "country")!== false)//note!== cannot be used with!=, otherwise you cannot distinguish between false and 0
{//
Header (' location:/china/indexphp ');
}elseif (Strpos ($_server[' http_host '), "BBS")!== false)
{
Header (' location:/bbs/forum.php ');
}
Else
{//Show home page
Header (' location:/templets/default/index.htm ');
}