I managed to create the /login url to redirect me in /wp-login.php page
In my .httacces I have the following code
RewriteRule ^login$ wp-login.php [NC,L]
In the functions.php (in my custom theme) I added this
add_filter('site_url', 'wplogin_filter', 10, 3);
function wplogin_filter( $url, $path, $orig_scheme )
{
$old = array( "/(wp-login\.php)/");
$new = array( "login");
return preg_replace( $old, $new, $url, 1);
}
The problem is how to disallow access to wp-login.php page without disabling it. With the solution above both url's are visible /login and /wp-login.php
How can I "hide" the wp-login.php permenantly without usign a plugin?
I once used this in my .httaccess file.
Code:
<Files "whatever.php">
require all denied
require host localhost
require ip 127.0.0.1
require ip xxx.yyy.zzz.aaa
</Files>
This prevents any external entry to whatever.php
You don't really have to hide it. Just redirect access to the home page - or any other page.
add_filter( 'login_url', 'my_redirect_login', 10, 3 );
function my_redirect_login(){
if ($_SERVER['REQUEST_URI']!='/wp-login.php') return;
header( 'Location: '.home_url(null, 'https') );
exit;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.