How To Block Malicious Visitor And Websites Using .htaccess

As most of us know the importance of .htaccess file for a web hosting account, here you can know one of the most useful utilities of this file. It’s possible to block users or websites which are causing any malicious activities on your website. This utility not only makes your website more secured but also saves your money which is needed to install any third-party security software within your web hosting account.

The Apache module ‘mod_rewrite’ is needed when you want to block the access of your website by referrer in .htaccess. In most of the hosting plans of Web Hosting India, this module comes as an inbuild with any particular web hosting package. This module helps you to deny access to all the traffic which is coming from a particular domain (IP)

Following is the way to Block traffic from a single referrer

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} suspecteddomain\.com [NC]
RewriteRule .* – [F]

Following is the way to block traffic from multiple referrers

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} suspecteddomain\.com [NC,OR]
RewriteCond %{HTTP_REFERER} anothersuspecteddomain\.com
RewriteRule .* – [F]