How a virtual host binds to a subdirectory in a Web site root directory

Source: Internet
Author: User

Most virtual hosts cannot modify the root directory of a Web site. Can be achieved through. htaccess.

Apache host general support. Htaccess pseudo-static, that can be implemented to bind the domain name to subdirectories, a space multiple sites.

Application Example: Binding www.xxx.com to htaccess directory

root directory. htaccess content

<ifmodule mod_rewrite.c>/#  binding www.xxx.com to subdirectories htaccessrewritecond%{http_host} ^  %{request_uri}!^/htaccess/^ (. *) $ htaccess/$1? Rewrite [L,QSA]# can be bound to multiple, just repeat the three lines of code and change the domain name, directory name on the line </IfModule>

. htaccess content in the htaccess directory

<ifmodule mod_rewrite.c>/# bind only domain access, other domain 301 jump rewritecond%{http_host}!^www\ . xxx\.com$ [Nc]rewriterule (. *) http://www.xxx.com/$1 [l,r=301]# processing of htaccess directories under the binding directory Rewritecond%{request_uri} ^\/ htaccess\/%{query_string}!^ (. *)? Rewrite#Rewriterule ^ (. *) $/%{request_uri}/%{request_uri}/$1? Rewrite [L,QSA]</IfModule>

If the requirements for a bound subdirectory are not high, the. htaccess file does not need to be established under the subdirectory.

How a virtual host binds to a subdirectory in a Web site root 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.