6 years ago (2015-03-26)  Hundred Encyclopedias |   First to comment  5 
post score 0 times, average 0.0

Since the opening of Wang Boyuan’s blog, the author has been harassed by malicious registration and robot advertisement comments on more than one occasion.Yesterday, I received an ad comment and found that the user IP that the review user fills in is the same as the IP of the user. Undoubtedly, this shows that this is a comment of the network robot brush.So I had an idea to directly block this IP to access my blog.The following describes my solution.

How the virtual host masks a specified IP or network segment

In general, virtual hosts do not provide the ability to shield IP access in host management. Of course, it is much more convenient if you have them.In fact, even if the virtual host provider does not provide the ability to block specified IP access, we can implement it very simply. The method is very simple: Add the IP blocking field in the htaccess file.(The writing of the htaccess file and the role of an article in front of me is quite detailed explanation, if you have a strong interest in anti-theft chain, 301 redirects, custom error pages, etc., you may wish to look at this article: 21 Very useful .htaccess tips and tricks.

Prohibit designated user IP access

If you want to block a specific IP you can use:

If you want to block multiple IP addresses, just add a few more deny from

If you need to shield the entire IP segment, you can use

If you only want to block a part of the IP in the IP segment,

Allow only specified IP access

The method is very simple, replace the above deny from allow from, deny from allow replaced from, for example:

Users of IP segment to are allowed to access. Other IPs cannot be accessed.

Custom 403 error page

The IP that restricts access will respond to 403 errors when accessing the website, but sometimes the banned IP may be misjudged. You can customize your own 403 error page, prompting the visitor that there is no access or the IP is blocked, and can be provided on the web page The way to appeal. Pictured: How the virtual host masks a specified IP or network segment  


Add the following code in htaccess:

Error/403.html Fill in the path according to the actual situation. The address points to the 403 page written by yourself.  


This article has been printed on copyright and is protected by copyright laws. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click the "Sponsoring Author" below to call the author!

Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/web-hosting-how-to-block-specified-ip-or-network-segments-2.html

Post comment


No Comment


Forget password?