Home > Article > CMS Tutorial > How to change the login address in wordpress
In recent days, the default login address of the small site has been attacked (scanned), an average of hundreds of times a day. Although it looks like nothing, it may be knocked away. But there is a contingency in everything! Although the small station is not important. Originally, the IP was blocked directly, but the IP is not fixed these days, so I simply changed the default login address! Below are several commonly used modification methods
Method 1
##Plug-in modification——Stealth Login Page
Install the plug-in in the background and find the Stealth Login Page in the settings properties. For settings, please refer to the picture below: After completion, the interface is as follows:Method 2
Add the following code to theme functions.php:
//后台访问地址修改 add_action('login_enqueue_scripts','login_protection'); function login_protection(){ if($_GET['psu'] != 'papapa')header('Location: https://www.yflad.cn/'); }After the modification is completed, the login address in the background will become https://domain name/wp-login.php?psu=papapa. If it is not this address, it will automatically jump to https://domain name/. It is followed by the ?psu=papapa parameter. There are three parameters that can be customized
psu, papapa, https://domain name/
function login_protection(){ if($_GET['psu'] != 'papapa'){ $url = "https://www.yflad.cn";echo "<script language='javascript' type='text/javascript'>"; echo "window.location.href='$url'"; echo "</script>"; } } add_action('login_enqueue_scripts','login_protection');The above code is a jump implemented through JS, and the effect is the same.
Method 3
Modify the WordPress program
1. Rename the WordPress program Modify the wp-login.php file in the root directory as you like, such as zhangsan.php, and then open this file with a code editor. Ctrl H replaces all wp-login characters with zhangsan, save and exit. 2. This step can be ignored. Find the general-template.php file in the wp-includes directory, open it with an editor, and use Ctrl H to replace all wp-login characters with zhangsan. Then search for the variable $login_url and change this variable to the following:$login_url = site_url('404.html', 'login');The 404.html can be customized
Summary
Personally recommend method two. Method one, for people with obsessive-compulsive disorder, you can install one less plug-in and never install one more plug-in; method three, you need to modify the core program of WordPress, maybe after WordPress is updated, you need to modify it again. Therefore, the method of modifying the core program is not highly recommended. Of course, if you disable automatic updates of WordPress, it is recommended that you combine method two and method three. The current website is thisThe above is the detailed content of How to change the login address in wordpress. For more information, please follow other related articles on the PHP Chinese website!