Home  >  Article  >  CMS Tutorial  >  How to change the login address in wordpress

How to change the login address in wordpress

angryTom
angryTomOriginal
2019-08-02 13:36:133728browse

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:

How to change the login address in wordpress

After completion, the interface is as follows:

How to change the login address in wordpress

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/

If you use this method, the prompt will occur Error can be replaced by the following:

function login_protection(){
   if($_GET['psu'] != 'papapa'){
   $url = "https://www.yflad.cn";echo "<script language=&#39;javascript&#39; type=&#39;text/javascript&#39;>";
   echo "window.location.href=&#39;$url&#39;";
   echo "</script>";
   }
  }
   add_action(&#39;login_enqueue_scripts&#39;,&#39;login_protection&#39;);

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(&#39;404.html&#39;, &#39;login&#39;);

How to change the login address in wordpress

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 this

The 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn