The Learning Center is a place where parents and teachers can learn, plan, and prepare to inspire young minds through through this blog. You will benefit from the expertise and experience of our community of parent-teachers who are contributing content.

Our goal is to make education surprisingly easy for you at home or in the classroom. You can confidently achieve your education goals for your children and students. Start exploring the Learning Center now!
Top posters
HAMADA (885)
885 Posts - 66%
BRIM (168)
168 Posts - 13%
boualem02 (97)
97 Posts - 7%
sasuna (48)
48 Posts - 4%
tanita (44)
44 Posts - 3%
razane (26)
26 Posts - 2%
23 Posts - 2%
tanita- (17)
17 Posts - 1%
12 Posts - 1%
mayssa (11)
11 Posts - 1%
Display results as :
Advanced Search

Go down
Number of posts : 885
Age : 58
Registration date : 2007-12-17

default How to block a whole country from visiting your website

on Sun Jul 10, 2011 9:30 pm
How to block a whole country from visiting your website

There are times when you may want to ban visitors from a certain country from viewing your website, the reasons for this can be many.

You can block people from viewing your website using rules in your firewall IP tables but if you dont have access to that, you can edit the .htaccess file and add a list of IPs to be blocked, you can get the whole IP range from a country from countryipblocks.

Select one or more country you want to block on home page of and press Choose Countries

How to block a whole country from visiting your website Ishot-115

Now on next screen you can see set of command, copy it and paste it to your .htaccess file, in case if you don’t have it in ftp then kindly talk to your host or create one using notepad or another text editor. This code having set of IP from countries you selected and it simply reject visitors request from those countries.

How to block a whole country from visiting your website Ishot-114

Upload that .htaccess file into root of your domain using a ftp client. Every time when a visitor request your site from server it look into .htaccess file and if IP address of that visitor fall with in range of all denied IPs of your .htaccess then it will simply deny visitor request.

However this solution may cause server overload if many requests are made from that country, another easier way to do this, is by banning people from accessing your website according to their browser language set up, for example to ban people who is using a Chinese internet browser you will add to your .htaccess file:

RewriteRule .* – [F]

THis will generate error 403 message, and the visitor will get a “Forbidden” message when visiting your page, but it can be changed to something else. The zh-CN is the browser setting for Chinese, this can be changed to any other language you like.
Back to top
Permissions in this forum:
You cannot reply to topics in this forum