How to set up two blog sites for WAN network virtual hosting?

Source: Internet
Author: User
Tags hosting

Anonymous user
Links: http://www.zhihu.com/question/28491981/answer/47442420
Source: Know
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

Take WAN network of Cloud virtual host to try the next, with. Htaccess can successfully build two stations.
One. Create a file in the root directory. htaccess
Two. Create a COM and CN two folder in the root directory.
Three. Add the following to the. htaccess file.
Rewriteengine on
Rewritebase/
#不带www的301重定向到带www.
Rewritecond%{http_host} ^abc\.com$ [NC]
Rewriterule ^ (. *) $ http://www.abc.com/$1 [l,r=301]
Rewritecond%{http_host} ^abc\.cn$ [NC]
Rewriterule ^ (. *) $ http://www.abc.cn/$1 [l,r=301]
#访问域名为 http ://ABC.com or http://www. ABC.com files or directories that are not/com/files and that do not exist
#重定向到 the/com/file. For example: http://www. abc.com/1.html The actual access to the file is 1.html under/com/
Rewritecond%{http_host} ^ (www\.)? abc\.com$ [NC]
Rewritecond%{request_uri}!^/com/
Rewritecond%{request_filename}!-f
Rewritecond%{request_filename}!-d
rewriterule ^ (. *) $/com/$1 [L]
#重定向首页到 the/com/file directory.
Rewritecond%{http_host} ^ (www\.)? abc\.com$ [NC]
Rewriterule ^ (/)? $ com/index.php [L]
#以上是设置 http://www. ABC.com access to the/com/file directory,
#以下是设置 http://www. abc.cn access to the/cn/file directory.
Rewritecond%{http_host} ^ (www\.)? abc\.cn$ [NC]
Rewritecond%{request_uri}!^/cn/
Rewritecond%{request_filename}!-f
Rewritecond%{request_filename}!-d
Rewriterule ^ (. *) $/cn/$1 [L]
Rewritecond%{http_host} ^ (www\.)? abc\.cn$ [NC]

Rewriterule ^ (/)? $/cn/index.php [L]
#以下设置访问地址既不是. http ://ABC.com is not http://www. redirect The abc.cn to http://www. abc.com Domain name
Rewritecond%{http_host}!^ (www\.)? abc\.com$ [NC]
Rewritecond%{http_host}!^ (www\.)? abc\.cn$ [NC]
Rewriterule ^ (/)? $ http://www. ABC.com [l,r=301]

That's it, you can.http://www. abc.com Access the/com/directory under the root directory,http://www. abc.cn Access to the/cn/directory, reached a million-net virtual host built two different stations. There is a problem that you visithttp://www. abc.com/com/ Orhttp://www. abc.cn/com/ and accesshttp://www. abc.com Is the same effect, so that you have to set robots.txt to prohibit search engines from accessing the/com/and/cn/directories.

How to set up two blog sites for WAN network virtual hosting?

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.