Please wait while we load your page...
 

Announcements

HTACCESS Magic :: Article :: Deny Visitors by Referrer





Results 1 to of

Deny Visitors by Referrer

Please note that restricting access on the basis of referrer is highly unreliable since many browsers may not pass referrer. For example, browsers set maximum privacy to not pass referrer. Further, referrer can be spoofed of faked. NOT recommended!

To block a single referrer, use the following Rewrite lines:

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


The Rewrite lines instruct the Apache Web Server to block traffic originating from otherdomain.com.

To block multiple referrers, use the following:

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


The Rewrite lines instruct the Apache Web Server to block traffic originating from otherdomain.com and anotherdomain.com. You add more in a similar manner.

Blocked referrers will be shown a "403 Forbidden" server error message. You can customise this error message by following the 'Error Documents' by adding the following:

ErrorDocument 403 /403.html

Then, create a 403.html page in root.

Note 1: To use Rewrite, (1) site must be hosted on an Apache web server, (2) mod_rewrite module must be compiled into Apache, and (3) mod_rewrite must be enabled for your domain.
Note 2: R=301 is a permanent redirect, and is the most efficient and "Search Engine Friendly" method for redirection. Alternatively, you can use R=302 for temporary redirect if the redirect is not permanent.

Last Revised: 2015-07-07

Live Chat Not Available