fr600 Posted August 4, 2008 Share Posted August 4, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/118014-allow-ip-blocks-with-htaccess-block-rest/ Share on other sites More sharing options...
elflacodepr Posted August 4, 2008 Share Posted August 4, 2008 I took this from a website, in your .htaccess file you will write this: ## USER IP BANNING <Limit GET POST> order allow,deny deny from 42.12.5.34 deny from 212.173.53. deny from 69.242. allow from all </Limit> Heres how it works * 42.12.5.34 (Blocks a specific IP address) * 212.173.53. (Blocks ALL IPs within the range 212.173.53.xxx) * 69.242. (Blocks ALL IPs within the range 69.242.xxx.xxx) * 81.158.3 (Blocks ALL IPs within the range 81.158.3xx.xxx.xxx) Quote Link to comment https://forums.phpfreaks.com/topic/118014-allow-ip-blocks-with-htaccess-block-rest/#findComment-607093 Share on other sites More sharing options...
fr600 Posted August 4, 2008 Author Share Posted August 4, 2008 Does this mean that for "122.202.0.0 - 122.202.31.255" I'll have to write 32 different entries? I can't do that, otherwise my htaccess will be like 1000 line long. The list IP I showed here is just an example which will help me to understand how it works and I can use the knowledge with the rest. There must be a shorter way. I found like 100s of websites like that, but that doesn't help. Hoping for a better solution. Quote Link to comment https://forums.phpfreaks.com/topic/118014-allow-ip-blocks-with-htaccess-block-rest/#findComment-607105 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.