如何阻止我的网站访问某个已知 IP 地址?

发布于 2024-07-29 03:20:57 字数 59 浏览 2 评论 0原文

我想阻止某个特定 IP 地址访问我的网站,我该怎么做?

使用 htaccess 或?

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

using htaccess or ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜巴黎 2024-08-05 03:20:57

我突然想到,在 .htaccess 中,输入以下内容“

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

不是 100% 确定”,所以请告诉我它是否有效。

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.

请帮我爱他 2024-08-05 03:20:57

如果您使用 PHP,请将其放入配置文件中。 根据需要替换字符串和变量以更改 IP 地址或仇恨级别。

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

我更喜欢这个:

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

如果他们足够刷新页面,他们可能会发现我在说什么。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文