Using rewrite rules to seal off each other's IP

Source: Internet
Author: User
Tags root directory

In many cases, access to an IP can easily result in CPU 100% (for example, some search engine's fixed crawl, others a large number of collection site), this time we have to use some effective means to seal off the other side of the IP, so that he can not consume the resources of the server, IP method There are many kinds of, if your WEB server Install the Rewrite module, you can also try to use the Rewrite rules to seal off each other's IP.

1, for example, we redirect a specific IP directly to Baidu homepage, in the site root directory of the. htaccess file to add code:

Rewritecond%{remote_addr} 123.123.123.123 [NC]

Replace 123.123.123.123 This IP with the IP you want to restrict

2, if you want to implement multiple IP, you can write this:

Rewritecond%{remote_addr} 123.123.123.123 [OR]

Rewritecond%{remote_addr} 124.124.124.124 [NC]

Rewriterule ^ (. *) $ http://www.baidu.com/$1 [r=301]



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.