. htaccess pseudo static (URL rewrite) bind domain names to subdirectories implement subwebs

Source: Internet
Author: User

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 htaccess.800m.net to htaccess directory

root directory. htaccess content

<ifmodule mod_rewrite.c>rewriteengine onrewritebase/# binding htaccess.800m.net to subdirectories Htaccessrewritecond%{HTTP_HOST } ^htaccess\.800m\.net$ [Nc]rewritecond%{request_uri}!^/htaccess/rewriterule ^ (. *) $ htaccess/$1? Rewrite [L,QSA] #可以绑定多个, just repeat the last three lines of code and change the domain name, directory name on the line </IfModule>

Even if the "." In the Http_host It is also possible to implement binding htaccess.800m.net without backslashes, because "." Can match any one character.

. htaccess content in the htaccess directory

<ifmodule mod_rewrite.c>rewriteengine onrewritebase/#只许绑定的域名访问, other domain 301 jump rewritecond%{http_host}!^htaccess\ .800m\.net$ [Nc]rewriterule (. *) http://htaccess.800m.net/$1 [l,r=301] #对绑定目录下htaccess目录的处理RewriteCond%{request_uri } ^\/htaccess\/[Nc]rewritecond%{query_string}!^ (. *)? Rewrite
#htaccess. 800m.net/htaccess actually accesses Htaccess.800m.net/htaccess/htaccessrewriterule ^ (. *) $/%{request_uri}/%{request_ Uri}/$1? Rewrite [l,qsa]</ifmodule>

Of course, if the requirements for a bound subdirectory are not high, you do not need to create a. htaccess file under the subdirectory.

. htaccess pseudo static (URL rewrite) bind domain names to subdirectories implement subwebs

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.