You can block users or sites that originate from a particular domain is another useful trick of .htaccess.
For blocking access by referrer in .htaccess requires the help of the Apache module mod_rewrite to make out the referrer first. This module is installed by default on most of the servers . So, to deny access all traffic that originate from a particular domain (referrers) to your website, use the following code given below:
Steps to Block traffic from a single referrer:
RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} badsite\.com [NC]
RewriteRule .* – [F]
Steps to block traffic from multiple referrers:-
RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} badsite\.com [NC,OR]
RewriteCond %{HTTP_REFERER} anotherbadsite\.com
RewriteRule .* – [F]
Related posts:
- Trick to find a Bad bot with the help of htaccess
- How to Disable Hotlinking of the Images Using .htaccess file?
- How to prevent an htaccess file from being viewed
Posted under Linux Hosting
This post was written by admin on October 18, 2008



















