This post was updated 1189 days ago and some of the ideas may be out of date.
来分享一下怎么样加固WordPress
1.屏蔽登陆错误提示
错误:为用户名xxx指定的密码不正确 忘记密码?
错误:无效用户名 忘记密码?
像这样,他会提示你是用户名错了还是密码错了,这样可以试探出用户名然后慢慢暴力破解密码
解决这个问题其实很简单
在主题的 functions.php 中插入以下代码
function failed_login() {
return '自定义错误提示信息';
}
add_filter('login_errors', 'failed_login');

然后,保存,你再次输入错误的用户名或密码,他就会显示你自定义的提示

2.登陆页地址修改
我们先安装 All In One WP Security (安装过程不再详述,大家应该都会的)
安装后我们到暴力破解-重命名登陆页


注意:修改后,Nginx请添加伪静态规则:
location /
{
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
或者 Apache 请在.htaccess下添加以下规则:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
然后即可通过此链接登陆
参与讨论