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.
ACF (3)
Admin Column (4)
Amps (9)
Breadcrumbs (2)
CSS (6)
Custom post types (4)
Custom Taxonomies (3)
Customizer (4)
Furniture (3)
Hooks & Filters (2)
Jquery (9)
LAMP (9)
Login (5)
Meta boxes (6)
Multisite (2)
My Code (1)
Open Graph Meta Tags (1)
Pedals (9)
Redirects (2)
SEO (4)
Theme Building (5)
Title Tags (2)
Tuners (3)
Turntables (2)
Typography (3)
Uncategorised (61)
User Roles & Capabilities (2)
White labeling (7)
Working with Images (11)
Working with videos (2)
WP Database (1)