How To Block Visitors From Specified Domain Or IP Addresses ?

Everybody wants traffic but here is an option to block traffic from certain domain or IP.

For blocking visitors from referring domain add the following code in .htaccess file changing domain.com with domain you like to block:

RewriteEngineon
RewriteCond %{HTTP_REFERER} domain.com [NC]
RewriteCond %{HTTP_REFERER} subdomain.domain.com [NC]
RewriteCond %{HTTP_REFERER} baddomain. [NC]
RewriteRule .* – [F]

For blocking traffic from certain IP add the following code in .htaccess file changing the IP address to IP you like to block:

allow from all
deny from 118.165.13.117

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.