Banning Users From Your Website

If you pay attention to your statistics you may sometimes see a specific domain or IP address that is visiting your site entirely too much to be a real live human being. You may begin to suspect it is not legitimate traffic and that it is a webbot or some other non-human that is wasting your bandwidth. In these cases you can easily ban the offending visitor by using an .htaccess file in the root (base) directory of your site, or in a specific directory if you do not want the ban to be site-wide.

The root directory will either be /public_html or /httpdocs or /domain-www, depending on the server type you are on.

Simply upload a file named .htaccess (the period is important) to the root directory containing the following lines of code. Pay close attention to the example syntax and replace the domain1, domain2 or 111.222.333.444 with the domains or IP addresses you you want blocked. Note the \. used instead of just the period in the domain names.

You do NOT need to put both of the following sets of code in your .htaccess file, choose whether or not you want to ban by referrer or by IP address. If you already have an .htaccess file there, you can add these it:

SITE REFERRER BANNING (by domain name)

RewriteEngine on
# Options +FollowSymlinks

RewriteCond %{HTTP_REFERER} domain1\.com [NC,OR]
RewriteCond %{HTTP_REFERER} domain2\ [NC,OR]
RewriteCond %{HTTP_REFERER} domain3\.net [NC]
RewriteRule .* – [F]


<Limit GET POST>
order allow,deny
deny from 111.222.333.444
deny from 555.666.777.888
allow from all

Leave your comments

Post comment as a guest

0 / 300 Character restriction
Your text should be in between 10-300 characters
terms and condition.
  • No comments found

Get The Latest Browsers



News Letter

Sign up for news letter