Shopping Cart Forum

Go Back   eShop Forums - eCommerce Help Forum for Shopping Cart Owners. > Tech Corner > PHP/HTML/CSS/JavaScript and Servers
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
PHP/HTML/CSS/JavaScript and Servers Pick up tips and exchange info on the technical side of having a web presence.

click here for ink cartridges for all types of printer
Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 15-08-2007, 12:29 AM
Lawrence Lawrence is offline
Forum Admin
 
Join Date: Aug 2007
Location: Kenley, Surrey, UK
Posts: 1,226
Thanks: 2
Thanked 82 Times in 82 Posts
Default How to use .htaccess to block IPs and domains from your website.

If you find yourself with a nuisance user or bot that won't go away then this is the way to block them at server level.

If it doesn't already exist, you will need to create a file on your server called .htaccess. If you are using Windows you will need to create a file such as htaccess.txt, upload it to your server then rename it to .htaccess as Windows doesn't like this form of filename.

Place one of the following examples in your .htaccess file with your own choice of IP(s)/domain(s).

This method will block a single IP
Code:
order allow,deny
deny from 65.36.241.81
allow from all
If you find that the abuser uses several IPs within a block then you can deny access to the whole IP block like this

Code:
order allow,deny
deny from 65.36.241
allow from all
You can even use
deny from 65.36
to block a greater range of addresses, though you should be very careful with blocking whole address ranges because you may end up blocking innocent users in the process. Also bear in mind that if it's a user you are trying to block that many people use dynamic IPs.

This is the way to block a domain.

Code:
order allow,deny
deny from internetseer.com
allow from all
Again you have to be careful how you use this due to the risk of blocking innocent users. For example if you used deny from aol.com you would deny access to everyone from AOL!
__________________
Lawrence
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-07-2008, 10:40 PM
tuk485 tuk485 is offline
Member
 
Join Date: Jul 2008
Posts: 14
Thanks: 0
Thanked 1 Time in 1 Post
Default

Great tutorial Lawrence.
It may be worth pointing out that this may not work on a shared hosting environment through.
Keep up the good work!
__________________
DesignandHosting.co.uk
"affordable website design, hosting, email and ecommerce solutions"

Last edited by tuk485; 04-07-2008 at 10:53 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
.htaccess


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Buy 1 Get 1 FREE Domains topebaydog The Water Cooler 0 29-08-2008 02:27 PM
Domains pupsandpets eCommerce for Beginners 11 05-02-2008 10:16 PM
How to use mod_rewrite to block bad bots with .htaccess Lawrence PHP/HTML/CSS/JavaScript and Servers 0 30-10-2007 04:25 AM
How to 301 redirect non-www URLs to www ones and vice versa using .htaccess Lawrence PHP/HTML/CSS/JavaScript and Servers 0 26-10-2007 02:21 PM
Can I block an IP with php? PeterC PHP/HTML/CSS/JavaScript and Servers 4 08-08-2007 04:55 PM

Google

Edible Graphics, Affordable E-Commerce, Web Shops & Custom Form Scripts
Vista Print
tech news, product reviews, the latest home and business technology, the latest in digital imaging


Content Relevant URLs by vBSEO 3.0.0