Htaccess to block ip
Websites are naturally geeks’ guinea pigs. You will get much more spam if you get a website to comment on or something. They just don’t stop. Try and try. You will find it very much annoying. You can pause them. Not stop but it will give you peace I think. Now open any text editor and
Type codes from below .
order allow,deny deny from 127.0.0.2 deny from 127.0.0.1 allow from all
Now put your desired IP, each in a new line by that pattern. You can use 58.97.. to block the next IP. And save that file by .htaccess. upload that file to the root of your website, maybe /public_html/. If you have a .htaccess, then edit that file and put the above codes after all codes in your .htaccess after existed codes.
Now let you want to allow a particular page or file to be accessed by only a particular IP or IP range and Deny access for all other users or visitors, You have to put the below codes in .htaccess.
<Files login.php>
order allow,deny
deny from 127.0.0.2
deny from 127.0.0.1
deny from 127.0.*.*
allow from 192.168.23.7
allow from all
</Files>
*to allow
Now if you want to deny for a particular folder then just open an htaccess file to that folder by having this code :
order allow,deny deny from 127.0.*.* allow from
192.168.23.7
deny from all
So now by the above code, you will only be allowed to access the folder by 192.168.23.7 and deny it from all other IPs. Change according to yours.