A garment factory is mainly engaged in foreign trade, design clothing for export to Europe and America, all English websites, but most of our website's access IP addresses come from China, chinese counterparts copy your ideas and styles (such as zencart, opencart, magento, and other B2C e-commerce systems), and may also initiate CC and DDoS attacks. How can we disable domestic IP addresses?
You can use either of the following methods to shield IP addresses in China on a foreign trade website (both are strongly recommended ):
1. Use the. htaccess File
In. htaccess, such:
Errordocument 403 http://www.XX.com // This line is optional, meaning that when the IP segment is not allowed to open will jump to this page
Order deny, allow // written in the English Input Method
Allow from 210.249.1.3 // enter your own IP address or IP address segment here to be allowed to access
Allow from 220.240.3.0/24 // enter your own IP address or IP address segment to allow access
Deny from 58.56.0.0/15 // ip address segment for which access is denied
There is also a simple method: blockacountry this website can generate online. htaccess file blocking based on the country you want to shield Code , Generate download and upload to the server.
The disadvantage of shielding IP addresses: If you know that you have used the IP address shielding technology, you can still bypass the shielding by using a foreign proxy server or a foreign VPN to access your website smoothly.
2. Shielding Chinese operating systems (by determining the operating system version of the client)
1. the PHP code is as follows:
$ Client_sys_language = $ _ server ["http_accept_language"]; // System Language
If (preg_match ("/^ ZH-CN/I", $ client_sys_language )){
Echo "Exit;
}
2. JavaScript code:
<SCRIPT type = "text/JavaScript">
If (navigator. Language)
VaR Language = navigator. language;
Else
VaR Language = navigator. browserlanguage;
If (language. indexof ('zh ')>-1) document. Location. href = 'nddbc.html ';
</SCRIPT>