469,336 Members | 5,695 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,336 developers. It's quick & easy.

.htaccess to block a country

Hello. I recently found a rather lengthy list of IP addresses to block. They are from an another country and I'm in the US. However when I just uploaded the .htaccess, I found that I'd blocked myself from my website, too.

So I must be doing this wrong. Here is a sample of what I'm doing:

<Files *>
order allow,deny
allow from all
deny from netvigator.com
deny from baidu.com
deny from .hk
deny from .cn
deny from picsearch.com
deny from misc.yahoo.com.cn/help.html
deny from 198.17.7.0/24
deny from 202.0.110.0/24
deny from 202.0.176.0/22
deny from 202.4.128.0/19
deny from 202.4.252.0/22
</Files>

<Files .htaccess>
order allow,deny
deny from all
</Files>


This is a sample except I have about 500 lines of deny from IP's. Is that too many. How can I block a country easier?

Thanks
Jun 22 '07 #1
3 6670
pbmods
5,821 Expert 4TB
Heya, satchel. Welcome to TSDN!

You should be able to block a range of IPs by leaving off trailing numbers. For example:

Expand|Select|Wrap|Line Numbers
  1. Deny from 202.4
  2.  
would create a deny rule for all IPs that start with 202.4.

mod_authz_host (for Apache 2.2).
mod_access (for Apache 1.3).
Jun 23 '07 #2
Motoma
3,237 Expert 2GB
Perhaps if you explained more acutely what you are trying to do, we could help you devise a better solution for you.
Jun 26 '07 #3
Hello,

To block a certain country you can block it's ip range. If you look for a handy tool to assist you with this you can go to block a country. You can simply select the countries you want to block or deny access to following the site will create you a .htaccess document for your server.

Wildcard
Jan 7 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by John | last post: by
3 posts views Thread by rossputin | last post: by
reply views Thread by Stoco | last post: by
reply views Thread by Jack Hambabo | last post: by
5 posts views Thread by Nosferatum | last post: by
reply views Thread by sanedt | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.