Blocking users and websites Via htaccess

Web Server HostingYou 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:

  1. Trick to find a Bad bot with the help of htaccess
  2. How to Disable Hotlinking of the Images Using .htaccess file?
  3. How to prevent an htaccess file from being viewed

Posted under Linux Hosting

This post was written by admin on October 18, 2008

Tags: ,

Leave a Comment

Name

Email

Website

Comments

More Blog Post

Next Post: