How to Block Visitors using .htaccess in WordPress

To block a visitor in your WordPress site using this method, you need to know the IP address of that visitor. Adding this snippet into your .htaccess file, that user will see a error message when trying to access into your site.

<Limit GET POST PUT>
order allow,deny
allow from all
deny from x.x.x.x
</Limit>

Remember to replace “x.x.x.x” with the IP address of the visitor you want to block.

If you need to block more than one visitor, then add their IP addresses like this:

<Limit GET POST PUT>
order allow,deny
allow from all
deny from x.x.x.x
deny from y.y.y.y
deny from z.z.z.z
</Limit>