This article mainly introduces you to the method of using .htaccess to ban a certain IP from accessing the website. By setting the ban on access to a certain IP segment, it increases the security of the virtual host. The article uses pictures, texts and sample codes. The introduction is very detailed. Friends who need it can refer to it. Let’s take a look together.
Preface
For cost considerations, most webmasters do not purchase separate servers for many small websites, but use Virtual host. If the website is maliciously harvested or CC attacked by others, if you have server permissions, you can prohibit a certain IP segment from accessing the website. Some virtual hosts will also provide an IP blacklist function. If the virtual host does not support IP blacklist, it will be a headache. Linux virtual hosts commonly use .htaccess to set up pseudo-static, and .htaccess processing achieves pseudo-static. There are still many functions that have not been explored. The IP blacklist function can also be implemented through .htaccess. Not much to say below, let’s take a look at the detailed introduction
The method is as follows:
For example, if you want to prohibit access to 104.236.180.129, use Save the following code to the .htaccess file and upload it to the FTP root directory.
Order Deny,Allow Deny from 104.236.180.129
Access effect after setting:
The above is the detailed content of Method sharing: How to use .htaccess to ban an IP from accessing the website. For more information, please follow other related articles on the PHP Chinese website!