7 commonly used. htaccess code to organize IP access for a country

Source: Internet
Author: User

htAccess files (hypertext Access file) is a very powerful configuration file for Apache Web servers, and for this file, Apache has a bunch of parameters that allow you to configure almost any function you want.

Use. htaccess block search engine spider

Block out Baidu search engine

Baidu is the legendary violence search engine, does not follow the rules of the search engine, if you try to use Robot.txt to block, it is very congratulations, absolutely invalid. So be sure to use a more violent, tough way to do it, so through. Htaccess can be handled, if you want to block out some search engine (such as Baidu, Sogou, etc.), then please paste the following code into the Htaccess.txt file.

Setenvifnocase user-agent "^baidu" Bad_bot
Setenvifnocase user-agent "^sogou" Bad_bot
Setenvifnocase user-agent "^bloghoo" Bad_bot
Setenvifnocase user-agent "^scooter" Bad_bot
Deny from Env=bad_bot

Block out Google search engine

If you want to block the Google search engine, of course, can also be blocked by the. Htaccsee, just enter the following code on it, if you want to block with the violent Baidu search engine, then put these two programs in the same Htaccsee.txt file.

Setenvif user-agent "^googlebot" Google
Deny from Env=google

Use. htaccess to block a country's IP network segment

Sometimes they may draw the direction of the development of the site, there are not welcome to certain countries to visit, this time the first idea should be to lock the country's IP, but do not know where to start? Because do not know that the country's IP and Ben cannot lock, this time can through the "blockcountry" online tool website generated by the htaccess grammar to block the IP network segment of the country you want to block.

1th Step to block Country (http://www.blockcountry.com) homepage, first you will see a box, there are many countries in the box, please select the country you want to block, you can check, choose to complete, click below the ﹝block now! ﹞。

The 2nd step is to paste the code generated on the Web page into the htaccess file and store it. Apache will return a 403 error for rejected IPs.

htAccess files (hypertext Access file) is a very powerful configuration file for Apache Web servers, and for this file, Apache has a bunch of parameters that allow you to configure almost any function you want.

Use. htaccess block search engine spider

Block out Baidu search engine

Baidu is the legendary violence search engine, does not follow the rules of the search engine, if you try to use Robot.txt to block, it is very congratulations, absolutely invalid. So be sure to use a more violent, tough way to do it, so through. Htaccess can be handled, if you want to block out some search engine (such as Baidu, Sogou, etc.), then please paste the following code into the Htaccess.txt file.

Setenvifnocase user-agent "^baidu" Bad_bot
Setenvifnocase user-agent "^sogou" Bad_bot
Setenvifnocase user-agent "^bloghoo" Bad_bot
Setenvifnocase user-agent "^scooter" Bad_bot
Deny from Env=bad_bot

Block out Google search engine

If you want to block the Google search engine, of course, can also be blocked by the. Htaccsee, just enter the following code on it, if you want to block with the violent Baidu search engine, then put these two programs in the same Htaccsee.txt file.

Setenvif user-agent "^googlebot" Google
Deny from Env=google

Use. htaccess to block a country's IP network segment

Sometimes they may draw the direction of the development of the site, there are not welcome to certain countries to visit, this time the first idea should be to lock the country's IP, but do not know where to start? Because do not know that the country's IP and Ben cannot lock, this time can through the "blockcountry" online tool website generated by the htaccess grammar to block the IP network segment of the country you want to block.

1th Step to block Country (http://www.blockcountry.com) homepage, first you will see a box, there are many countries in the box, please select the country you want to block, you can check, choose to complete, click below the ﹝block now! ﹞。

The 2nd step is to paste the code generated on the Web page into the htaccess file and store it. Apache will return a 403 error for rejected IPs.

7 commonly used. htaccess code to organize IP access for a country

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.