WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to change wordpress login url without using .htaccess, should be a manual process, so example.com/login will not redirect to example.com/wp-login.php so example.com/login will be the login page?

share|improve this question
up vote 6 down vote accepted

I wrote a post about it a few weeks ago WordPress Easy Login URL whiteout htaccess, but if you dont want to read then here is the code in a plugin form:

Plugin Name: Nice Login URL
Plugin URI: http://en.bainternet.info
Description: Simple plugin to redirect login/register to a nice url
Version: 1.0
Author: bainternet
Author URI: http://en.bainternet.info

// Add rewrite rule and flush on plugin activation
register_activation_hook( __FILE__, 'NLURL_activate' );
function NLURL_activate() {

// Flush on plugin deactivation
register_deactivation_hook( __FILE__, 'NLURL_deactivate' );
function NLURL_deactivate() {

// Create new rewrite rule
add_action( 'init', 'NLURL_rewrite' );
function NLURL_rewrite() {
    add_rewrite_rule( 'login/?$', 'wp-login.php', 'top' );
    add_rewrite_rule( 'register/?$', 'wp-login.php?action=register', 'top' );
    add_rewrite_rule( 'forgot/?$', 'wp-login.php?action=lostpassword', 'top' );

//register url fix
function fix_register_url($link){
    return str_replace(site_url('wp-login.php?action=register', 'login'),site_url('register', 'login'),$link);

//login url fix
function fix_login_url($link){
    return str_replace(site_url('wp-login.php', 'login'),site_url('login', 'login'),$link);

//forgot password url fix
function fix_lostpass_url($link){
    return str_replace('?action=lostpassword','',str_replace(network_site_url('wp-login.php', 'login'),site_url('forgot', 'login'),$link));

//Site URL hack to overwrite register url
function fix_urls($url, $path, $orig_scheme){
    if ($orig_scheme !== 'login')
        return $url;
    if ($path == 'wp-login.php?action=register')
        return site_url('register', 'login');

    return $url;
share|improve this answer
mmm, happy to have your plugin :D – Hasan Jan 5 '13 at 6:05
is that it redirect to example.com/wp-login.php? – Hasan Jan 5 '13 at 14:50
Sir, you may not realize this but with this code, you fixed almost everything that was broken in WP, Buddy Press and woocommerce :) – anber Oct 8 '14 at 10:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.