An .htaccess file is a simple text file. To block IPs, create a file called .htaccess in your root folder (alongside your home page) that contains the following lines:
This will allow all traffic, except that from the single IP address 18.104.22.168, as well as any IP address from 22.214.171.124-126.96.36.199. Blocked visitors will see the error message "Your IP Address has been blocked...". You can of course edit this message. However, you can not serve a custom error document, since access to that error document will also be blocked.
Order Allow, Deny
Deny from 188.8.131.52
Deny from 2.3.4
Allow from All
ErrorDocument 403 "Your IP Address has been blocked from accessing this server."
Note: Using this code does require that your ISP allow you to customize your server using .htaccess, and the ErrorDoc line will only work if your ISP has enabled that functionality.