Apache implementation prohibits Chinese browser access and 301 redirect Methods _linux

Source: Internet
Author: User

Deployment prohibits Chinese browsers from accessing Web sites
in the htaccess file in the root directory of the Web site, add the following statement

############################################
# Enable rewrites
 
Options +followsymlinks
rewriteengine On
 
Rewritecond%{http:accept-language} ^zh-cn.*$ [Nc,or]
rewritecond%{http:accept-language} ^zh.*$ [NC]
rewriterule ^.*$ http://www.baidu.com [r=302,l]

Several examples of implementing 301 redirects
1. redirect sjolzy.cn to www.sjolzy.cn

This redirect is designed to make the domain name unique, is the website SEO must do, the back redirects www.sjolzy.cn to sjolzy.cn is also for the same reason, but the form is different.
Open the. htaccess file and add the following rules. (The following rule is for the primary domain name, and the subdomain is to be modified)

Rewriteengine on
rewritecond%{http_host}!^www.sjolzy.cn$ [NC]
rewriterule ^ (. *) $ http://www.sjolzy.cn/$1 [l,r=301]

2. redirect www.sjolzy.cn to sjolzy.cn

Rewriteengine on
rewritecond%{http_host}!^sjolzy.cn$ [NC]
rewriterule ^ (. *) $ http://sjolzy.cn/$1 [L,R=301]

3. REDIRECT oldsjolzy.cn to www.newsjolzy.cn

Rewriteengine on
rewritecond%{http_host}!oldsjolzy.cn$ [NC]
rewriterule ^ (. *) $ http://www.newsjolzy.cn/$1 [ L,R=301]

4. redirect oldsjolzy.cn to newsjolzy.cn

Rewriteengine on
rewritebase/
rewritecond%{http_host}!oldsjolzy.cn$ [NC]
rewriterule ^ (. *) $ http:// newsjolzy.cn/$1 [l,r=301]

5. redirect sjolzy.cn/file/file.php to othersjolzy.cn/otherfile/other.php

Rewritecond%{http_host} ^www.sjolzy.cn$
rewriterule ^file/file.php$ http://www.othersjolzy.cn/otherfile/ other.php [R=301,l]

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.