How to Disable or Redirect the Default WordPress Login Page (Wp-Login.php)?

disable or redirect wp login php

If you have a custom WordPress login form or you do not want anyone to access the default login form, due to security reasons or any other reason, you can set a redirect for the wp-login.php page.
You could set a redirect simply in the .htaccess or the site's Nginx config file, but this will break the ability to login, logout and the forgot password feature. This is so beacuse the wp-login.php script handles all these features.

In your theme's folder, you will find the 'functions.php' file. You need to add the following code in the functions file :

function custom_login(){
 global $pagenow;
 //  URL for the HomePage. You can set this to the URL of any page you wish to redirect to.
 $blogHomePage = get_bloginfo('url');
 //  Redirect to the Homepage, if if it is login page. Make sure it is not called to logout 
     or for lost password feature
 if( 'wp-login.php' == $pagenow && $_GET['action']!="logout" && $_GET['action']!=
© 2024 WPOven Inc. All rights reserved. WPOven® and WordPress® are registered trademarks.
WPOven is the best Managed WordPress hosting for agencies and businesses that want to succeed. With Unlimited sites hosting option, its easy to use and manage, so you can focus on growing your business. 
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram