Block Unwanted Visitors To Your Website With .htaccess

Friday October 29, 2010 by  

spambotUnwanted visitor won’t bring you any good or benefit. Unwanted visitor may harm your website or server and wasting your money indirectly. And since they don’t bring you any benefit and may cause harm to your server that will effect your loyal visitors/readers, so we need to block them.

So who is the unwanted visitors? Here some of them:
1. Scrape Bot
2. Vulnerable finder bot
3. Spam bot
4. Unknown spider/crawling bot
5. DDOS attack

Those bot doesn’t do anything good for you, they stealing content, injecting malicious code, spam your comment box, and crawling your website for nothing. They just wasting your bandwidth, increase server load, slow down your server which may cause less experience for your loyal visitors. This should be stop.

You should stop those kind of visitors, you don’t need them. To block them you can do it with .htaccess.

To block by ip addresses:

<Limit GET,POST>
order allow,deny
deny from xxx.xxx.xxx.xxx
allow from all
</Limit>

To block by specific ISP:

<Limit GET,POST>
order allow,deny
deny from some-evil-isp.com
allow from all
</Limit>

To block by spider name:

<Limit GET,POST>
order allow,deny
SetEnvIfNoCase User-Agent "libwww-perl" bad_bot=1
deny from env=bad_bot
allow from all
</Limit>

To block by User agent:

RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^First_string_here [OR]
RewriteCond %{HTTP_USER_AGENT} ^Another_string_here [OR]
RewriteCond %{HTTP_USER_AGENT} ^Last_string_here
RewriteRule ^(.*)$ http://your.domain.com/custom_error_page.html

To see the visitor’s ip address, user agents, or spider name you can see in your access_log. Or in WordPress you can install Statpress plugin to see your visitors detail and statistic. If you see something unusual just block them. You don’t need such visitors.

What people search:

Other Interesting Articles:

Post comment as twitter logo facebook logo
Sort: Newest | Oldest

I cannot understand what you mean. You want to turn 3 url with 1 single url?

Hi,
i am surya from india. Nice information about .htaccess.
i have site url like
www.mysite.com/sms/friendship/f1.html
www.mysite.com/sms/goodmorning/g1.html
www.mysite.com/sms/goodmorning/g2.html

but i want to display url like

www.mysite.com/sms/

when user seeing my site

How i can do this.
it is possible using .htaccess ? if yes then please help me .

I have been having some spamming issues of late so this is a welcome tip. keep up the great work. :)

Thanks mate :)