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  1.1.1.1

These commands block access to all users that use IP address 1.1.1.1

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 1.1.1.1
</Files>

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