Apache. htaccess implementation of the two-level domain name method of universal domain names

Source: Internet
Author: User
Tags net domain

First, the domain name to do a pan-resolution *.xxxx.com resolution to your space IP, independent IP virtual host support pan-resolution, do not need to bind domain names can access the site.
Second, the establishment of BBS, home directory, the CMS uploaded to the root directory, the forum uploaded to the BBS directory, will ucenterhome upload to the home directory.
Third, open Notepad to copy the following code into, save as. htaccess file, upload to the root directory.
The contents of the. htaccess file are as follows: (take 111cn.net domain name as an example)
Rewriteengine on
DirectoryIndex index.php index.html index.htm
#让www. xxx.cn access to the root directory cms
Rewritecond%{http_host} ^www.111cn.net$
Rewritecond%{request_uri}!^/
Rewritecond%{request_filename}!-f
Rewritecond%{request_filename}!-d
Rewriterule ^ (. *) $/$1
Rewritecond%{http_host} ^www.111cn.net$
Rewriterule ^ (/) $/index.php [L]
#让home. xrnic.cn access to the home directory Ucenterhome
Rewritecond%{http_host} ^home.111cn.net$
Rewritecond%{request_uri}!^/home/
Rewritecond%{request_filename}!-f
Rewritecond%{request_filename}!-d
Rewriterule ^ (. *) $/home/$1
Rewritecond%{http_host} ^home.111cn.net$
Rewriterule ^ (/) $ home/index.php [L]
#让bbs. xrnic.cn Access BBS Directory Forum
Rewritecond%{http_host} ^bbs.111cn.net$
Rewritecond%{request_uri}!^/wap/
Rewritecond%{request_filename}!-f
Rewritecond%{request_filename}!-d
Rewriterule ^ (. *) $/bbs/$1
Rewritecond%{http_host} ^bbs.111cn.net$
Rewriterule ^ (/) $ bbs/index.php [L]
According to the above method can be a space to establish n sites, of course, you can also put other top-level domain name to the subdirectory, to achieve a space to build multiple web site functions

The first one:! (exclamation point) means No. For example, a condition: to determine whether the previous page URL to access this page contains sex characters, you can use this: Rewritecond%{http_referer}! (Sex)
The second: < is less than the meaning of teststring < Condpattern.
The third: > is greater than the meaning, teststring < Condpattern.
Fourth one: = Meaning of equality. ",", = three and the usual program language use, ",", = function similar.
Fifth:-D is a directory. To determine if teststring is not a directory can do this:!-d
Sixth:-F is a file. Determine if teststring is not a file can be this way:!-f
Seventh:-S is a normal file with a size. Determine if teststring is not a normal, size-capable file:!-s
Eighth:-L is a shortcut file. To determine if TestString is not a shortcut file can do this:!-l
Nineth:-X is a file and performs permissions. To determine if teststring is not a file and execute permissions as well:!-x
Tenth:-F checks whether the teststring is a legitimate file and is accessed through the server-wide current set of access controls. This check is done through an internal subrequest, so you need to use this feature carefully to reduce server performance.
11th:-U checks whether the teststring is a valid URL and is accessed through the server-wide current set of access controls. This check is done through an internal subrequest, so you need to use this feature carefully to reduce server performance.

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.