Block IP using htaccess-how

Block IP using htaccess-how

Posted by: watchtower
Posted on: 2008-05-14 11:05:00

Can someone post a simple "how to" block an IP address using htaccess?

And I mean a SIMPLE how to!

Re: Block IP using htaccess-how

Posted by: scjessey
Posted on: 2008-05-14 11:29:00

Easy:

deny from xxx.xxx.xxx.xxx

That's all there is to it.

-- si-blog --

Re: Block IP using htaccess-how

Posted by: sdayman
Posted on: 2008-05-14 15:30:00

Really? You don't need an "access order allow, deny" type line?

-Scott

Re: Block IP using htaccess-how

Posted by: Notaskapache
Posted on: 2008-05-14 16:40:00

In reply to:

Can someone post a simple "how to" block an IP address using htaccess?


http://www.htaccesselite.com/deny-user-based-their-address-vt40.html

Re: Block IP using htaccess-how

Posted by: scjessey
Posted on: 2008-05-15 06:02:00

In reply to:

Really? You don't need an "access order allow, deny" type line?


No, you don't. It really is as simple as just "deny from IP".

-- si-blog --

Re: Block IP using htaccess-how

Posted by: scjessey
Posted on: 2008-05-15 06:03:00

@Notaskapache

Don't be an ass all your life, Bob.


-- si-blog --

Re: Block IP using htaccess-how

Posted by: askapache
Posted on: 2008-05-15 16:48:00

No that is incorrect. It depends on previous rules and the inheritance depending on where the deny directive is and what order and/or satisfy and/or allow directives are set.

There is a shell script that scans your dreamhost logfiles and automatically creates the correct blocking .htaccess code here.

_____

 _  _|  _  _  _  _|_  _
(_|_\|<(_||_)(_|(_| |(/_
|

Hey, your site is cool. I was shocked by the md5 cracker tool.

Re: Block IP using htaccess-how

Posted by: scjessey
Posted on: 2008-05-15 19:34:00

In reply to:

No that is incorrect.


The OP was looking for a simple answer, and a basic "deny from" will work in most cases. I've got a very complex .htaccess file on my blog site, and I'm able to successfully block IPs with that rule.

-- si-blog --

Re: Block IP using htaccess-how

Posted by: norm1037
Posted on: 2008-05-16 01:59:00

There is a site called http://corz.org/ which contains some very useful,original and accurate htaccess tips and tricks at http://corz.org/serv/tricks/htaccess.php which if you scroll down it you will see that, as Simon rightly says, you can get away with the simplest of lines such as:-

If you have no friends

deny from all

or if you have a whole friend

allow from xxx.xxx.xxx.xxx

So you see, the line from scjessey in his post, ideally suits your needs.

deny from xxx.xxx.xxx.xxx


You can add other entries into an .htaccess file, as per the excellent examples at http://corz.org/ , as you need them.




--
Norm


Opinions are my own views, not DreamHosts'.
I am NOT a DreamHost employee OK! mad

Act on my advice at your own risk!

Re: Block IP using htaccess-how

Posted by: Notaskapache
Posted on: 2008-05-16 05:28:00

In reply to:

There is a site called...


Spammer! laugh

RTFM is good and good for you. Order can makes a differences. Sytems defaults are not always same. Good practice to specify for sureness.

Re: Block IP using htaccess-how

Posted by: askapache
Posted on: 2008-05-29 18:02:00

Thanks patrick! pretty cool.

_____

 _  _|  _  _  _  _|_  _
(_|_\|<(_||_)(_|(_| |(/_
|

But I don't want to promote that :-(

Simply just want to leave the world a piece of peace.

Tags: ip address