Forum Moderators: phranque

Message Too Old, No Replies

htaccess question, blocking ips &showing 403 page

ip block htaccess show 403

         

kazrod

7:52 pm on Jan 26, 2004 (gmt 0)

10+ Year Member



Hi all

Im fairly new to the htaccess file and Ive been searching for a way of blocking certain isps by either specific IP address or partial IP address (eg 123.123.123.123 or 456.456. ) or by IP name (eg internetprovider.abc.com )

I have looked around this forum and Ive come up with the following from various posts, and would like someone to tell me if it will work.

SetEnvIf Remote_Addr ^123\.123\.123\.123$ banit
SetEnvIf Remote_Addr ^internetprovider.abc.com$ banit
SetEnvIf Remote_Addr ^456\.456\. banit
SetEnvIf Request_URI "^/403\.htm$" allowit
<Files *>
order deny,allow
deny from env=banit
allow from env=allowit
</Files>

thanks

kazrod

panic

8:14 pm on Jan 26, 2004 (gmt 0)

10+ Year Member



I'm not sure if it will work or not, but the best way to check is to try it out on your own IP.

If that doesn't work, try looking into the ReWrite rules/conditions and using those instead.

jdMorgan

8:30 pm on Jan 26, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



kazrod,

Welcome to WebmasterWorld [webmasterworld.com]!

Your code looks fine to me -- I use exactly that sequence on several live sites.

Jim

kazrod

1:37 am on Jan 27, 2004 (gmt 0)

10+ Year Member



thanks 'panic' and 'jdMorgan'.

Ive tried the code in my htaccess file, but it doesnt seem to work.

Ive had to return to using

<Limit GET>
order allow,deny
allow from all
deny from 12.345.67.89
</Limit>

which isnt really what I want as I cant get this to block hosts eg deny from ahost.somewhere.com wont work, neither will it work when I use only part of an IP, the only combo that works is as Ive shown above and this prevents the personalised 403 page from showing.

Is there anything Ive missed on the original that I posted or do I need to activate anything to get it to work?

kazrod

jdMorgan

4:45 am on Jan 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



karod,

You probably don't need to "activate" anything to get it to work, but SetEnvIf requires Apache 1.3 or later, and there are additional limits on functionality up to Apache 1.3.13.

Could it be that your server is pre-Apache 1.3?

Jim

kazrod

11:27 am on Jan 27, 2004 (gmt 0)

10+ Year Member



Yes, this could be the problem, I have contacted my host to find out which version they are using.

thanks.

kazrod

jdMorgan

4:14 pm on Jan 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



kazrod,

No need to wait for the help desk, ask your server to tell you [webmasterworld.com].

Jim

kazrod

12:21 am on Jan 28, 2004 (gmt 0)

10+ Year Member



Oh dear, Im about to reveal my true ignorance!

I was working on the basis I had an apache server, it turns out its Zeus/4.1

Id like to thank you for your time (and for pointing me at that util for the header)

.htaccess has been integrated to work on zeus, but it doesnt appear to have the functionality of apache.

Im going to go and do some reading (in between kicking myself )

thanks again for the help,

kazrod

jdMorgan

5:02 am on Jan 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



kazrod,

Well, too bad... We don't have a Zeus forum!

(Once you do figure out how to get it working, though, you'll probably be conscripted as the moderator for a new WebmasterWorld Zeus forum) ;)

Jim