Using. htaccess to deny access to a website from an ip address

Source: Internet
Author: User

What should I do if I find that an ip address often attacks our website or I plan to reject the ip address from accessing our website for other reasons? The following describes how to deny access from an ip address through. htaccess.

Edit the. htaccess file and enter the following content:

Order allow, denydeny from 110.120.16.11deny from 108.8.32.allow from all

Save the preceding content and put it under the root directory of the site to reject the specified ip address from accessing the website. In the code above, the second line rejects the ip address 110.120.16.11 from accessing our site, the third line is to reject users in the IP segment 108.8.32.0-108.8.32.255 from accessing our site. Of course, if you want to deny everyone access to your site? Use deny from all directly. In addition to IP addresses, the prohibited information can also be set by domain names, as shown below:

Order allow, denydeny from baidu. comdeny from www. google. cnallow from all
Articles you may be interested in
  • How to use. htaccess anti-leech website Images
  • Disable the list directory using. htaccess
  • Set the default homepage of a website through. htaccess
  • How does one modify the default homepage of a website through. htaccess?
  • 10 practical. htaccess code snippets
  • . Htaccess: how to set images in a directory of anti-leech
  • Use Apache htaccess to prevent image leeching
  • Use the GZip compression function of PHP to compress website JS and CSS files to accelerate Website access.

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.