| | #1 |
| New Warrior Member Join Date: 2008 Location: , , .
Posts: 9
Thanks: 0
Thanked 3 Times in 3 Posts
|
I try to do following Blocking Website Access by Country with PHP | Azulia Designs but when I check my site with my country ip it still access and error occur because it not found .php in ip_files folder. So, I want to know other methods that easy and works fine. Thank you very much. |
| |
| | #2 |
| Warrior Member War Room Member Join Date: 2012
Posts: 16
Thanks: 0
Thanked 3 Times in 3 Posts
|
Well try to find an API, you can find a public one easily that can tell you what country is of IP and then you can write php code to let allow to redirect it somewhere. Google for public api's to get country by IP
|
| |
| | #3 |
| -------------- War Room Member Join Date: 2012
Posts: 261
Thanks: 33
Thanked 80 Times in 58 Posts
|
I do it via htaccess instead of php. If you can't get the php to work it's an option for you.
|
| | |
| |
| | #4 |
| Active Warrior Join Date: 2013 Location: AU
Posts: 57
Thanks: 0
Thanked 1 Time in 1 Post
|
You can do it usign htaccess or you should have a IP to country database and then you can restrict using php script
|
| |
| | #5 |
| Active Warrior Join Date: 2011
Posts: 35
Thanks: 1
Thanked 4 Times in 4 Posts
|
Note that if anyone is using proxy it can avoid IP filtering.
|
| | |
| |
| | #6 |
| SKT Wordpress Themes War Room Member Join Date: 2013 Location: Nagpur
Posts: 65
Thanks: 5
Thanked 28 Times in 11 Posts
|
You can use xforwarded for header info: if($_SERVER["HTTP_X_FORWARDED_FOR"] != ""){ $IP = $_SERVER["HTTP_X_FORWARDED_FOR"]; $proxy = $_SERVER["REMOTE_ADDR"]; $host = @gethostbyaddr($_SERVER["HTTP_X_FORWARDED_FOR"]); }else{ $IP = $_SERVER["REMOTE_ADDR"]; $proxy = "No proxy detected"; $host = @gethostbyaddr($_SERVER["REMOTE_ADDR"]); } |
| | |
| |
|
| Bookmarks |
| Tags |
| block, countries, php |
| |