How does the website block specific country ip/language visitors while allowing search engine spiders and their own access?

Source: Internet
Author: User
Keywords wordpress googlebot centos ngix php
Tags geoip
Environment: VPS, Centos, Ngix, Wordpress
1. To block all Chinese IP and Chinese language visitors
2. Blocking proxy access
3. The above access jumps to a specific page or displays a specific text
4. Allow search engine spiders such as Googlebot access
5. Allow yourself to access

Ask for more, forgive me not to write PHP code ...

Reply content:

To block all Chinese IP and Chinese-language visitors
It's not easy! At the beginning of your PHP file index.php, add a sentence
Provides a way to block a specific country IP, DNS is not resolved.

The Incapsula free version provides shielding national functionality. Purely theoretical analysis, I do not know whether to help:
    • Php:geoip-manual , PHP appears to have a geo module, you can access the IP address of the geographical analysis, if from the CN, processing off itself. (Usage introduction GEOIP use-PHP version )
    • Language, you can try to check the HTTP header's desired language and dispose of the zh-* yourself.

    • Agent Kung Fu Big This needless to say, but you can refer to the Wikipedia block table (
Phone answer. JS code to determine whether the browser's language header contains "zh, CN" Content, do a jump is not good place to change an English browser can access.
var BrowserLang = navigator.language || navigator.userLanguage;if (BrowserLang.substr(0, 3) == "zh-") {    location = "";}
  • Related Article

    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: 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.