如何配置 Apache 以对来自禁止 IP 地址的 POST 查询提供自定义响应?



有人试图入侵我的Wordpress网站,所以我和他们搞砸了。他们使用脚本将密码猜测直接发布到 wp-login.php 页面。我可以用我的 .htaccess 文件轻松阻止它:

<limit POST>
order deny,allow
deny from 188.213.49.210
</limit>
ErrorDocument 403 /fakelogin.php

但是开机自检不会重定向到我的 403 错误页面。对于那些好奇的人来说,假登录页面每次猜测密码时都会强制下载整个乐高电影:

<?php
$file_url = '/rsc/The.Lego.Movie.2014.m4v';
header('Content-Type: application/octet-stream');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename="" . basename($file_url) . """);
echo "Fake page";
readfile($file_url);
?>

我对php的了解是有限的。当他向wp-login.php开机自检时,我该如何执行上述任务?如果需要.php我愿意编辑wp登录。

根据您的问题,这是一个简单的解决方案。

如果有申请表188.213.49.210php将重定向到下载页面。

<?php
$blocked_IP= $_SERVER['REMOTE_ADDR'];
if(preg_match("/188.213.49.210/",$blocked_IP)) { 
header('Location: https://example.com/The._Lego_Movie_2014_download_page.php');
exit; //<-- Here 
}
?>

最新更新