Witicles Experts Online Articles Directory
     
Witicles Experts Articles Directory Witicles Experts Articles DirectoryWiticles Experts Articles DirectoryWiticles Experts Articles Directory

Welcome, Guest!     Sign Up    Sign In
Sponsored Ads

Create Free Website or Blog with Hubpile

Serious Money






Author Box


Josh TechcasterJosh Techcaster
My job is to help you do your own job better through up-to-date information about Technologies and how they can make your work better and easier.
Joined 4 years ago
From Abuja, Nigeria
Total Articles 10

Recent Articles From Author

# US shale oil stares into abyss with Opec ready push it over
# How Nigeria Made Top 10 Internet Users List In The World
# CarDealsNg: Nigeria's Best Car Sales Website
# Honda Accord 2004 Sedan

Namecheap.com Namecheap.com



Become A Witicles.Com Expert Contributor Today



Shop for Books online in Nigeria at kpiBooks.com.ng Order your favourite books online now, Save the stress & Pay online or with cash at Your Doorstep!


We help our esteemed clients develop web strategy that works!
Call us @ +234 803 578 3880




Authors Spotlight
Gboyega Adedeji  Gboyega Adedeji
Gboyega Adedeji is a Veteran Writer on Witicles.comVeteran Author
238 Articles
   I am a Nigerian and an Ambassador of Christ sent to Nigeria for the cause of His Kingdom. By divine-making, I read, teach and ... from Abuja, Nigeria


Free Online Articles Editor  Free Online Articles Editor
Free Online Articles Editor is a Veteran Writer on Witicles.comVeteran Author
137 Articles
   We challenge the minds of people towards mental and attitudinal shift and National transformation. We are the Editorial team of Witicles.... from Abuja, Nigeria


Abiola Benjamin Obayomi  Abiola Benjamin Obayomi
Abiola Benjamin Obayomi is a Veteran Writer on Witicles.comVeteran Author
241 Articles
   Real Estate is my Profession. The change we need in Nigeria begins with all of us doing things differently. Collectively, we can make Nigeri... from Ile-Ife, Osun State


Omolara Adedeji  Omolara Adedeji
Omolara Adedeji is a Veteran Writer on Witicles.comVeteran Author
60 Articles
   I am a kingdom expander and I believe in the testimony of a transformed life as the greatest testimony of all. I am a voice of God for m... from Abuja, Nigeria



Sell Your Books online in Nigeria, Earn 80% from book sales


Top Articles
Top 10 Reasons for Nigeria's Undeveloped Economy
CONSAT: Nigeria DTH Cable Television That Challenges DsTV, MyTV, Startimes and Others
INSIGHTS On Tithes & Offerings from Brother Gbile Akanni
The Pyramid of Friendship: Secret of Effective Relationships
The Quick Fix for Nigeria's Underdevelopment and Unemployment


Recent Articles
Buhari Anti-Corruption Fight: Is It A Sham?
The Presidency and A Failed Coup: Let Us Make Sense of It
Saraki Impeachment Plot: How Easy Can It Be?
Who Is Afraid of Bukola Saraki?
Police Brutality: A Menace To Our Collective Existence


Recent Comments
Aerocity Escorts
Mahipalpur Escorts Link For The Entertainment
2 days ago www.24x7callgirls.com/call-girls-in-mahipalpur.html www.24x7callgirls.com/call-girls-in-dwarka.html www.24x7callgirls.com/call-girls-in-delhi.html www.24x7callgirls.com/call-girls-in-gurgaon.html www.callgirlsaerocity.com

Delhi Escorts
Ghaziabad Call Girls Hi Fi Female Company Escorts in Ghaziabad
2 days ago www.24x7callgirls.com www.24x7callgirls.com/escort-services www.24x7callgirls.com/call-girls-in-gurgaon.html www.24x7callgirls.com/call-girls-in-delhi.html www.callgirlsaerocity.com

Escort Services
ICG Adult Ads - Free Classified Adult Ads Site in India
2 days ago http://www.24x7callgirls.com | http://www.24x7callgirls.com/escort-services | http://www.24x7callgirls.com/call-girls-in-gurgaon.html | http://www.24x7callgirls.com/call-girls-in-delhi.html

Site Clouds
Witicles, Articles, Webnigerians,Experts, Submit Articles, Become A Writer, Writing, Technology, Leadership, God, Government, Management, Nigeria, Society, Culture, Authentic Articles
Social Sharing



Sponsored Ads


Namecheap.com
Article Category >>>Security

How To Block Bots, Ban IP Addresses With .htaccess

By Josh Techcaster       Mar 09, 2015


How To Block Bots, Ban IP Addresses With .htaccess

Got a spambot or scraper constantly showing up in your server logs? Or maybe there's another site that's leeching all your bandwidth? Perhaps you just want to ban a user from a certain IP address? In this article, I'll show you how to use .htaccess to do all of that and more!

Identifying bad bots

So you've noticed a certain user-agent keeps showing up in your logs, but you're not sure what it is, or if you want to ban it? There's a few ways to find out:

Once you've determined that the bot is something you want to block, the next step is to add it to your .htaccess file.

Blocking bots with .htaccess

This example, and all of the following examples, can be placed at the bottom of your .htaccess file. If you don't already have a file called .htaccess in your site's root directory, you can create a new one.

   #get rid of the bad bot
   RewriteEngine on
   RewriteCond %{HTTP_USER_AGENT} ^BadBot
   RewriteRule ^(.*)$ http://go.away/

So, what does this code do? It's simple: the above lines tell your webserver to check for any bot whose user-agent string starts with "BadBot". When it sees a bot that matches, it redirects them to a non-existent site called "go.away".

Now, that's great to start with, but what if you want to block more than one bot?

   #get rid of bad bots
   RewriteEngine on
   RewriteCond %{HTTP_USER_AGENT} ^BadBot [OR]
   RewriteCond %{HTTP_USER_AGENT} ^EvilScraper [OR]
   RewriteCond %{HTTP_USER_AGENT} ^FakeUser
   RewriteRule ^(.*)$ http://go.away/

The code above shows the same thing as before, but this time I'm blocking 3 different bots. Note the "[OR]" option after the first two bot names: this lets the server know there's more in the list.

Blocking Bandwidth Leeches

Say there's a certain forum that's always hotlinking your images, and it's eating up all your bandwidth. You could replace the image with something really gross, but in some countries that might get you sued! The best way to deal with this problem is simply to block the site, like so:

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://.*somebadforum\.com [NC]
RewriteRule .* - [F] 

This code will return a 403 Forbidden error to anyone trying to hotlink your images on somebadforum.com. The end result: users on that site will see a broken image, and your bandwidth is no longer being stolen.

Here's the code for blocking more than one site:

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://.*somebadforum\.com [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*example\.com [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://.*lastexample\.com [NC]
RewriteRule .* - [F] 

 

Banning An IP Address

Sometimes you just don't want a certain person (or bot) accessing your website at all. One simple way to block them is to ban their IP address:

order allow,deny
deny from 192.168.44.201
deny from 224.39.163.12
deny from 172.16.7.92
allow from all

The example above shows how to block 3 different IP addresses. Sometimes you might want to block a whole range of IP addresses:

order allow,deny
deny from 192.168.
deny from 10.0.0.
allow from all

The above code will block any IP address starting with "192.168." or "10.0.0." from accessing your site.

Finally, here's the code to block any specific ISP from getting access:

order allow,deny
deny from some-evil-isp.com
deny from subdomain.another-evil-isp.com
allow from all


From Witicles.Com: Thank you for the gift of your time. We appreciate you for reading this article published by Josh Techcaster. Witicles.Com is indeed your partner for your growth, effectiveness and maturity.

1294 Views


If you need to re-publish this ARTICLE, please cite this article - (http://witicles.com/how-to-block-bots-ban-ip-addresses-with-htaccess-257.html) and the Writer (Josh Techcaster)

Do You Find This Article Helpful?


Article Tags: how to block ip htaccess, how to block hackers
Save the Stress, Shop for Books Online in Nigeria - kpiBooks.com.ng
Article Source
Josh TechcasterAbout Josh Techcaster
Josh Techcaster Josh TechcasterJosh TechcasterJosh TechcasterJosh Techcaster

  

I love to help you with latest IT gists online. Join me again for more!





Social Sharing

If You Enjoyed This Article; Then, Share It On Your Social Network





     Copy This Short Link To The Article: http://i.witicles.com/s3J7u How To Block Bots, Ban IP Addresses With .htaccessHow To Block Bots, Ban IP Addresses With .htaccessHow To Block Bots, Ban IP Addresses With .htaccessHow To Block Bots, Ban IP Addresses With .htaccess



Post Comment


Article Comments

No comment found! Be the first to share your thoughts on this article!



Namecheap.com
Related Articles




Author's Articles





Related Books

Championship Fathering: How to win at Being a Dad

Coach Mom: 7 Strategies for Organizing Your Family Into An All-Star Team

Leading Your Child to Jesus

What Makes a Man Feel Loved: Understanding What Your Husband Really Wants







My Accounts Categories Useful Links Affiliate Links Follow Us
Witicles.com is not a mere article directory; but Trusted Online Article Directory of syndicated articles on 27 core topics, including health and fitness, finance, business and economy, life improvement, real estate, politics, leadership, management and education. Authors publish articles for free and share knowledge with potential customers.


My Accounts
Account details
Lost Password








News and Society (169)
Self Improvement (135)
Business and Economy (103)
Leadership (102)
Politics (67)
Arts & Entertainment (48)
Health & Fitness (126)
Religion and Kingdom (58)
Real Estate (16)
Computers & Technology (21)
About Us
Advertise With Us
Contact Us
How To Submit Articles
Article Writing Tips
Sitemap





Leadersoil
Hubpile
Pay4ebooks
kpiBooks
Fridayposts
Flickers of Hope Foundation





CentreNDL on Facebook  Facebook

CentreNDL on Twitter  Twitter

CentreNDL on Google+  Google+

CentreNDL Blog  Blog

Send Email to Hubpile  Email