Deny Visitors by Referrer Using .htaccess File


Prev Tutorial Next Tutorial

How to Deny Visitors by Referrer Using .htaccess File

The visitor blocking facilities offered by the Apache Web Server enable us to deny access to specific visitors based on where they have come from.

Syntax

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

The above lines tell the Apache Web Server to block traffic from the URL 'otherdomain.com'. The '[NC]' text after the referrer specifies it as not case-sensitive. Which prevents traffic from 'OtherDomain.com', 'otherdomain.com', 'OTHERDOMAIN.COM' and so on..

Block Multiple Referrers,

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} otherdomain\.com [NC,OR]
RewriteCond %{HTTP_REFERER} anotherdomain\.com
RewriteRule .* - [F]

Prev Tutorial Next Tutorial

Download Projects

Google Adsense Advertisements
Free Classified Site – Bedpage

Yahoo Advertisements