Forum Moderators: phranque

Message Too Old, No Replies

Allow IP blocks with htaccess, block the rest

         

veto

2:57 am on Aug 4, 2008 (gmt 0)

10+ Year Member



I'm looking forward to make my server private. I'd like to grant access to some specific IP blocks and deny access from the rest. I know it can be done using htaccess but I don't know how. These are some of the blocks that I'd like to allow access:

122.202.0.0 - 122.202.31.255
158.165.224.0 - 158.165.231.255
158.145.176.0 - 158.145.191.255
178.141.228.0 - 178.141.228.127
180.78.20.172 - 180.78.20.179
195.12.167.228 - 195.12.167.231
217.110.163.192 - 217.110.163.223

Moreover, I'd like to redirect the banned users to some other website like: www.google.com

Could you please help with this? Thanks.

jdMorgan

3:31 am on Aug 4, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See Apache mod_access. If you need more sophisticated conditional control, you may use mod_setenvif with mod_access, or you may prefer to use mod_rewrite.

Please see our Apache Forum Charter [webmasterworld.com] for information about getting the most from this forum, and for links to useful resources.

Thanks,
Jim