Without Plugin:
1. Add constant to wp-config.php
define(\'WP_ADMIN_DIR\', \'admin-area\');
define(\'SITECOOKIEPATH\', preg_replace(\'|https?://[^/]+|i\', \'\', get_option(\'siteurl\') . \'/\' ) );
define(\'ADMIN_COOKIE_PATH\', SITECOOKIEPATH . WP_ADMIN_DIR);
2. Add below filter to functions.php
add_filter(\'site_url\', \'wpadmin_filter\', 10, 3);
function wpadmin_filter( $url, $path, $orig_scheme ) {
$old = array( "/(wp-admin)/");
$admin_dir = WP_ADMIN_DIR;
$new = array($admin_dir);
return preg_replace( $old, $new, $url, 1);
}
3. Add below line to .htaccess file
RewriteRule ^admin-area/(.*) wp-admin/$1?%{QUERY_STRING} [L]
RewriteRule ^admin-area/?$ /wp-login.php [QSA,L]
RewriteRule ^admin-area/register/?$ /wp-login.php?action=register [QSA,L]
RewriteRule ^admin-area/lostpassword/?$ /wp-login.php?action=lostpassword [QSA,L]
Also you can redirect Using this function
add_action(\'login_form\',\'redirect_wp_admin\');
function redirect_wp_admin(){
$redirect_to = $_SERVER[\'REQUEST_URI\'];
if(count($_REQUEST)> 0 && array_key_exists(\'redirect_to\', $_REQUEST)){
$redirect_to = $_REQUEST[\'redirect_to\'];
$check_wp_admin = stristr($redirect_to, \'wp-admin\');
if($check_wp_admin){
wp_safe_redirect( \'404.php\' );
}
}
}
这里有一个很好的免费插件
Protect Your Admin NOTE : 在启动激活插件之前备份数据库。在开始激活插件之前备份数据库是非常重要的。