The method of implementing a subdirectory binding level two domain name by configuring the. htaccess file _linux

Source: Internet
Author: User
Tags net domain
Use Linux shared host, control surface version is Cpanel's friends know that he default binding the primary domain name root directory is public_html

So if you want to put the domain name yourdomain.com can directly access, it is necessary to all files directly into the public_html. At this time if you want to build a station, bbs.yourdomain.com, then the BBS directory and other PHP files or the main station folder mixed together, very detrimental to management.

The General Linux host supports the. htaccess file, so we can use the. htaccess file to implement the steering

The following is a blog directory and blog.shuxiong.net domain name for example to explain

Copy Code code as follows:

# Open function
Rewriteengine on

# you want to bind the two-level domain name
Rewritecond%{http_host} ^ (blog.)? shuxiong.net$

# point that subdirectory to the level two domain that you want to bind
# Here's an example of a subdirectory blog directory
Rewritecond%{request_uri}!^/blog/
Rewritecond%{request_filename}!-f
Rewritecond%{request_filename}!-d
Rewriterule ^ (. *) $/cms/$1

#这里改成要绑定的二级域名和要绑定的子目录
Rewritecond%{http_host} ^ (blog.)? shuxiong.net$
Rewriterule ^ (/) $ blog/index.php [L]

Save the above code as a. htaccess file and upload it to the root directory (e.g., public_html directory) in ASCII mode.

Windows can not be renamed to. htaccess, this time first named Abc.htaccess, upload to the server, with the FTP tool renamed to. htaccess is OK.

above. htaccess content is the target directory blog to point to level two domain name blog.shuxiong.net

such as blog.shuxiong.net, access to the directory directly to the blog

Supplemental: You must first bind a level two domain name to the host root directory (e.g., bind to www.abc.com directory)

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.