coderex
coderex

Reputation: 27845

how to block my site from one known IP address?

I want to block access of my site from one particular IP address, how can i do that.?

using htaccess or ?

Upvotes: 0

Views: 246

Answers (2)

Tyler Carter
Tyler Carter

Reputation: 61547

If you are using PHP, put this in your configuration file. Replace strings and variables as necessary to change the IP address or level of hatred.

<?php
$ip = 255.255.255.255;
if($_SERVER['REMOTE_ADDR'] == $IP)
{
    die("I Hate You");
}
?>

I prefer this one:

    $ip = 255.255.255.255;
    if($_SERVER['REMOTE_ADDR'] == $IP)
    {
        $array = array("I", "Hate", "You", "Alot");
        $message = $array[rand(0,3)];
        die($message);
    }

If they refresh the page enough, they might find out what I'm saying.

Upvotes: 1

falstro
falstro

Reputation: 35657

Off the top of my head, in .htaccess, put the following

order allow,deny
allow from all
deny from 10.my.ip.address

Not 100% sure, so please let me know if it worked.

Upvotes: 1

Related Questions