Website block Chinese Browser/English browser method

Source: Internet
Author: User

One opens the Apache configuration file httpd.conf.
Two will #loadmodule Rewrite_module Modules/mod_rewrite front of the # Remove
Three Add in httpd.conf:
<ifmodule mod_rewrite.c>
Rewriteengine on


#RewriteCond%{env:script_url} (?: Index|dispbbs) [ -0-9]+\.html
Rewriterule ^ (. *? (?: Index|dispbbs))-([ -0-9]+) \.html$ {getproperty (Content)}.php?__is_apache_rewrite=1&__ Rewrite_arg=$2
</IfModule>

Four to implement the ASP post URL to the PHP post map, in the third step between the <ifmodule mod_rewrite.c> and </IfModule> add:
Rewritemap toLowerCase Int:tolower
Rewritecond%{query_string} (?: Boardid|page|id|replyid|star|skin) \=\d+ [NC]
Rewriterule ^ (. * (?: Index|dispbbs)) \.asp$ {GetProperty (Content)}.php?${tolowercase:%{query_string}}&__is_ Apache_rewrite=1

Five save httpd.conf and restart Apache

In order to save the Web site's broadband, sometimes need to block some user access, of course, may also affect the screen language spiders.
The following code can prohibit non-Chinese browser users from accessing the Web site
Add in. htaccess to prevent foreigners from visiting our website

Rewritecond%{http:accept-language} ^en.*$ [NC]

Rewriterule ^/?$ abc_en.html [R=301,l][/box] can determine browsers used by viewers to screen non-Chinese browsers


A browser that masks Chinese, the method is
Rewritecond%{http:accept-language} ^zh-cn.*$ [NC]

Rewriterule ^/?$ abc_cn.html [r=301,l]

Can be used to determine browsers browser, so as to screen Chinese browser


Mainly relies on Apache has a powerful Address rewriting module (module mod_rewrite). You can also search for these settings at Google. Google can find a lot of relevant htaccess information. More functions, you can say that only you do not think not to do.    My own authentic sneakers often use htaccess rules to restrict access to some visitors, htaccess is a sharp weapon ah. [Box type= "Info"]apache has a powerful Address rewrite module (module mod_rewrite), which can be used for reference here and here. You can also search for these settings at Google. More functions, you can say that only you do not think not to do.
The general usage of this module is as follows:
1, this module is generally used in some programs of the framework of the Address bar rewrite. For example, WordPress uses this module on the address bar from write, to achieve a fixed connection. 2, according to user access to the browser user type redirected to different pages, such as: If users use mobile phone access to redirect to the WAP page and so on. 3, when the site directory structure changes, the use of Rewirte can resolve the old connection to jump to the new connection.
For example: Just put the following code in the. htaccess file, you can redirect the browser language to the Simplified Chinese viewer to the page you set abc.htm
Rewritecond%{http:accept-language} ^zh-cn.*$ [Nc]rewriterule ^/?$ abc_cn.html [/box]
-----------------------------------------------------------
Frankly speaking, China's copyright protection environment is not very good. Basically with Zen-cart Open shop people ten have nine and a half unwilling to peer to see their station ... So, what can we do to keep people at home from seeing their online stores?
The following method is simpler, which is to directly screen out Chinese browser access.
We open the Includestemplates template commonhtml_header.php
Add the following code above to implement: <script type= "Text/javascript" >if (navigator.language) var language = Navigator.language;elsevar Language = navigator.browserlanguage;if (language.indexof (' en ') >-1) document.location.href = ' abc_en.html '; </ Script>

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.