Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess deny all by ip address except those in united states?

I have a local Web site that I would like to tighten access to only those within the United States; or perhaps only within Florida. It's a Word Press site that has gotten hacked due to some weak code. I've seen two sources of IP address lists for .htaccess "allow deny" control by IP Address.

IP by Country/Continents: http://www.countryipblocks.net/continents/

Wizcrafts List: http://www.wizcrafts.net/htaccess-blocklists.html

What is the best approach for blocking everything except United States traffic? How would you approach the deny/allow? Would you deny other Countries or try to allow only the U.S.?

Thanks for any comments, Jeff

like image 614
jjwdesign Avatar asked Aug 14 '11 20:08

jjwdesign


People also ask

How do I restrict IP address in htaccess?

htaccess or you want to create settings for a list of addresses, all you need to do is: Create . htaccess file in your public_html folder. Add lines based on your preferences.

What does htaccess Deny from all do?

htaccess to make it happen. For example, deny from all is a command that will allow you to apply access restrictions to your site.

How do I deny access to my site with an .htaccess file?

htaccess IP deny access. To deny access to a block of IP addresses, simply omit the last octet from the IP address: deny from 123.456. 789.


2 Answers

Add this list to the .htaccess located on the root folder of your server.
It will only allow connections from the US.

ex .htaccess file:

allow from IP
203.31.234.0/24
129.230.176.0/20
etc...

like image 89
Pedro Lobito Avatar answered Sep 18 '22 23:09

Pedro Lobito


you can use deny from All in order to forbid access to your site!

In countryipblocks you can download all IPs from the area you want and add allow from IP to your .htaccess file! so only those IPs can access to your site!

Edit: Remember you can add IP range instead of one IP! I downloaded .htacees from that site, and that was ok!

like image 22
undone Avatar answered Sep 19 '22 23:09

undone