You can use .htaccess to block access to your website from single IP addresses or IP ranges.
The following syntax can be used to block with:
<RequireAll> Require all granted # Bloker enkelt IP Require not ip 192.0.2.1 # Bloker IP range Require not ip 192.0.2.0/24 # Bloker IP range Require not ip 192.0.2 </RequireAll>
And if you want to block all access except from some IP addresses:
Require ip 126.96.36.199/27 Require ip 192.0.2.1
Just add the relevant lines to the web hosting's .htaccess file.
To block selected countries, you can use this tool: https://www.ip2location.com/free/visitor-blocker
See also: https://httpd.apache.org/docs/2.4/howto/access.html#host
Article from the support category: PHP