How to block IP address by using a file .htaccess?

In order to block access to your site from certain IP addresses you can use file .htaccess.
You need to create this file in your folder www/[website]/ and add the following lines to the file:

Order Deny,Allow 
Allow from all
Deny from

These commands block access to all users that use IP address

Also, You can allow access to a specific file from a specific IP address:

<Files file.php>
    Order Deny,Allow
    Deny from all
    Allow from

Эти строки разрешат доступ к файлу file.php пользователям, которые используют IP-адрес