Knowledgebase: Cpanel
How do I ban a user from visiting my site?
Posted by Serhiy Hryva on 31 January 2011 06:35 PM
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\.com [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
(136 vote(s))
Not helpful

Comments (0)
Post a new comment
Full Name: