(it)gossips     Twitter     Advertise     Squidoo     Subscribe for FREE newsletter

How To Block IP Address with PHP scripts

February 7th, 2008 by | Filed under Uncategorized.

Your webmaster search is: how to block scripts from websites

i actually do this to my site ,i block some refferer IP address in my country because i’d like to know how if i block it D [i can't tell you why],if you want to block some refferer IP address or certain IP address or a subnet.we can use several scripts to do this.but because my site is php.so i use php scripts to blocks IP address. here is the scripts :

<?
$targetAddr = "202.46.129..*";  //yes is two dots\
$targetAddr2 = "222.124.224.147" ;
if (ereg($targetAddr, $_SERVER['REMOTE_ADDR']) ||
   ereg($targetAddr2, $_SERVER['REMOTE_ADDR']))
	{
       //remote address match, do something or don't do anything
       header( 'Location: http://backtracktutorial.com' ) ;
	}
?>

the blocked IP is 202.46.129.0\24 and 222.124.224. 147 and if this IP address open my site it will redirect to http://backtracktutorial.com. you can use and change this script.put it at header of your site (header.php).and and the blocked IP will redirect into another site. or you can left a massage.

but you need to know that the blocked pages is the front page.the main index template.you still can acces your wp-admin so you still can edit or post at your website like what i do.:D

Related Posts


[Read the rest on (it)gossips network: admin]

Subscribe to Our FREE Newsletter Now:

Enter your email address:

Viewing 4 Comments

 

Trackbacks

(Trackback URL)

close Reblog this comment
blog comments powered by Disqus Some people come to this post with this search term: php block ip, block ip php, Block My IP Address, address, block country php script, php block country, php ip block script, block ip php script, php blocking ip country address, country block php, block ip script php, php block ip address, WP block IP, how to block an IP address in PHP, php script block country, block IP address, how to block ip, how to block a country from your site and redirect to another page, block ip script, block countries php script, block ip address country, block countries php, ip address blocker, redirect ip address php, block ip outside country php, PHP Header IP-Address, php block ip from enter site, script php block ip, php block IP addresses by country, php block ip script, "IP"+"PC"+"with PHP", allow ip address in php, country block php scripts, website blocking ip php script, how can i block my ip address, block by ip .php script, PHP block subnet, php block ip address list file, blockipaddress.info, ip-address.php scripts, ip address locator script in php, block IP by country, acces premium, php script IP address location, how to ban ip address, how to block ip php, country block +php, block IP with header php, block ip adress open site, blocked because its IP address is uncategorized,