Change from wp-login.php to login

Twice I have to do it, in 2 blogs. Then I thought to do a tutorial to help someone else. I how it helps you too.

1) Redirect with .htaccess
the original .htaccess looks like that

BEGIN WordPress

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

END WordPress

so, after

RewriteBase /
add a new rule

RewriteBase /
RewriteRule ^login$ wp-login.php
Now you can access the login page using these 2 urls (/login and /wp-login.php). So we need to hide the wp-login.php links in your blog.

2) Change the links from wp-logins.php to /login
in your functions.php (or someone plugin) add this filter

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);
}
Now, every time wordpress call site_url(“wp-login.php?action=xxx”); this function will redirect to /login.

3) Notes
I think there are some few links to wp-login.php which wordpress make without use the filter ‘site_url’. So you need to look for ‘wp-login.php’ on /wp-include and /wp-admin and change it. You can use site_url(‘wp-login.php?[and the actions]’); instead the hard code link.

I think there is other way, but it worked well for me.
Any suggestion is very apreciated =)

I am also looking for how to change the wp-admin to admin.

I hope it can help.

https://wordpress.org/support/topic/how-to-change-from-wp-loginphp-to-login/
  • Categories