Home > Backend Development > PHP Tutorial > Use .htaccess to deny certain IP access to the website_PHP tutorial

Use .htaccess to deny certain IP access to the website_PHP tutorial

WBOY
Release: 2016-07-13 10:30:51
Original
1099 people have browsed it

What should we do if we find out that a certain IP frequently attacks our website or if we want to deny this IP access to our website for other reasons? Let’s share a way to deny access to a certain IP through .htaccess.

Edit the .htaccess file and enter the following content:

order allow,deny
deny from 110.120.16.11
deny from 108.8.32.
allow from all
Copy after login

Save the above content and put it under the root directory of the site to deny the specified IP from accessing the website. The second line of the above code is to deny the IP address 110.120.16.11 from accessing our site. The third line It is to deny users in the IP range 108.8.32.0 - 108.8.32.255 from accessing our site. Of course what if you want to deny everyone access to your site? Just use deny from all directly. In addition, in addition to filling in the IP address, the prohibited information can also be set by domain name, as follows:

order allow,deny
deny from baidu.com
deny from www.google.cn
allow from all
Copy after login

Articles you may be interested in

  • How to use .htaccess to prevent hotlinking website images
  • Using .htaccess ban list directories
  • Using .htaccess Set the default homepage of the website
  • How to modify the default homepage of the website through .htaccess?
  • 10 practical .htaccess code snippets
  • .htaccess How to set up anti-hotlinking for images in a directory
  • Use Apache’s htaccess to prevent images from being hotlinked
  • Use PHP’s GZip compression function to compress website JS and CSS files to speed up website access

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/764184.htmlTechArticleIf it is found that an IP frequently attacks our website or for other reasons, we intend to deny access to this IP What should we do when opening our site? Let’s share a way to pass...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template