views:

143

answers:

3

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

using htaccess or ?

A: 

How is the site hosted? This will have a large inpact on your options.

Irfy
@ifry: i don't understand? could you please elaborate more.?
coderex
Is your site hosted at a web hosting servfices ? Do you have full control over the server your site is on ? Is it a unix/windows/etc. box ? Are you using ruby/php/java/etc. ?
nos
oho am sorry am using shared hosing :(
coderex
@mittu: Who is the hosting providor? This will let us figure out if you have a control panel, of if we need to do this programatically.
Irfy
+1  A: 

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.

Chacha102
+1  A: 

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.

roe
@roe: let me try once ;-)
coderex
yes it is working fine :) Thank you roe
coderex