REQUEST - A Simpler Login URL Plugin for MU

Sarah wrote about Ozh's Simpler Login URL plugin back in January, but many people are having trouble getting it to work with multisite.

Seems easy enough... just use the WordPress Rewrite API to change
mysite.com/login/ into mysite.com/wp-login.php

(This would make things a lot easier for new WP users to get to their dashboards.)

Ozh's plugin works nicely for regular WP, but getting it to work on MU to be a common problem. If you read the comments on Ozh's plugin post, there are lots of MU users having issues getting it to work.

Also, see these threads:
https://premium.wpmudev.org/forums/topic/how-to-change-login-url
https://premium.wpmudev.org/forums/topic/changing-wp-login-wp-admin

I'd like to request a multisite-compatible version of this plugin. WPMU DEV has the technical knowhow to get these rewrite rules working for multisite networks.

I have tried Ozh's plugin on both our production server (Nginx, multisite) and my local MAMP install (multisite). Neither worked. I'm getting 404 errors when trying to access mysite.com/login/

James? Aaron? Any takers? Any +1's ?

  • James Farmer
    • CEO (of WPMU DEV, honest)

    Aaron's having a well deserved break, and I'm beasting all our other developers (who aren't also on holiday) with a billion other things, maybe in a few weeks but not before I'm afraid :disappointed:

    Also, there's a nasty tendency for us to get badmouthed every time we do a better version of another plugin... having said that though you;re right, this should be a nice easy one to knock out, and a generally good improvement to MS too!

  • nickd32
    • The Incredible Code Injector

    Glad Aaron's getting a little R&R !!

    Also, there's a nasty tendency for us to get badmouthed every time we do a better version of another plugin... having said that though you;re right, this should be a nice easy one to knock out, and a generally good improvement to MS too!

    I hear ya, but it's nothing a little positive PR couldn't fix. In this particular case, there is a good amount of evidence to show that the current plugin doesn't work for most (or perhaps all) MU installations.

    Suggestions:
    1. Give Ozh a mention or some credit/attribution on the plugin -- "based on the great tutorial/plugin Ozh wrote"
    2. Consider releasing it for free on the regular WP plugin directory

    Oh, and thanks in advance if you guys decide to develop this little plugin. IMHO, this will make it much easier for MU admins to teach their clients to login to their sites... and hopefully prevent all those emails like:

    "Hey, I lost that login link to my site again... What was it?"

  • Jonathan
    • The Incredible Code Injector

    Until this plugin request becomes real :wink:

    Here is something I am using to force redirect to mydomain.com/login/

    /* Usage: create page called login. Use login shortcode to create login form. Code will redirect users to new login page */
    
    add_action('login_init', 'redirect_login');
    function redirect_login() {
    
    	global $action;
    
    	if (empty($action) || 'login' == $action) {
    
    		wp_safe_redirect('http://mydomain.com/login/');
    		die;
    
    }
    }

    This is a temp fix until above mentioned requested plugin is realized to be able to change wp-login.php into /login/ :wink:

  • Aaron
    • CTO

    This is much better handled by a true rewrite rule in multisite, as the plugin was adapted from, something like:

    RewriteRule ^login/?$ /wp-login.php [NC,L]
    (untested)

    Using WP's built in rewrites is not such a good idea because you have to flush the rules option for every single blog, which is why that plugin doesn't work.

  • Jonathan
    • The Incredible Code Injector

    @Aaron,

    That is the issue - lol

    Sarah wrote about Ozh's Simpler Login URL plugin back in January, but many people are having trouble getting it to work with multisite

    https://premium.wpmudev.org/blog/daily-tip-get-a-pretty-login-url-for-wordpress/
    http://wordpress.org/extend/plugins/ozh-simpler-login-url/
    And Ozh's plugin is pretty much what you said and this is why we are dumb founded - with mu - It doesn't work :wink:
    Can't figure it out - it should work but it doesn't.
    This plugin request started by nickd32 came from these topics
    https://premium.wpmudev.org/forums/topic/how-to-change-login-url
    https://premium.wpmudev.org/forums/topic/changing-wp-login-wp-admin

    Jonathan.

    Sidenote: Welcome back. Hope you had a great holiday :wink:

  • Jonathan
    • The Incredible Code Injector

    @Aaron,

    Just tested your htaccess code...
    RewriteRule ^login/?$ /wp-login.php [NC,L]

    All I'm going to say is WTF - It works! - I tried this awhile ago, and it didn't work - I swear - lol.

    Okay so that solves the login rewrite.
    So user can now login at either
    domain.com/login/ or
    domain.com/wp-login.php

    Question: So now how do we redirect the wp-login.php to /login/

    Jonathan.

  • Jonathan
    • The Incredible Code Injector

    Aaron,

    Tried the redirect - didn't work. So tried various ways, you were close :wink:

    Okay Final Working htaccess edits for simplier login url

    # Redirect for wp-login.php to /login/
    Redirect 301 /wp-login.php?$ /login/
    # Rewrite wp-login.php to /login/
    RewriteRule ^login/?$ /wp-login.php [NC,L]

    Thanks Aaron this solved it.

    Jonathan

  • Jonathan
    • The Incredible Code Injector

    @gina

    Congrats on becoming a lifetime member - I see the shiny new slogan :slight_smile:

    -----------------------
    I spoke to soon. I am having issues with the redirect from wp-login.php to /login/
    It works great for root...but not subsites - I suspect the issue is because I am using multisite with subfolders.

    Would be great if someone with multisite subdomains set up could test. I don't have access to a subdomain multisite at the moment.

    Jonathan

  • Aaron
    • CTO

    @Jonathan -- will these rules be the same for NGINX, since there's no .htacess file?

    You'll have to translate into nginx specific rules.

    I spoke to soon. I am having issues with the redirect from wp-login.php to /login/
    It works great for root... I suspect the issue is because I am using multisite with subfolders.

    Ya, rules would be different/more complex with subfolders, you would need to use a rewrite to pull the blog url part and paste into new login url. Lots of google and trial/error.

  • Jonathan
    • The Incredible Code Injector

    Lots of google and trial/error

    Sounds like fun - good thing I only need it to work on root with subfolders setup :wink: Aren't I so lucky - lol.

    @nickd32,

    What Aaron said. And I haven't a clue - I am a newbie with nginx too. That is part of the problem - lol
    But the converter says this:

    rewrite ^/login/?$ /wp-login.php last;

  • nickd32
    • The Incredible Code Injector

    Any reason you guys would recommend rewriting to /wp-login.php (as opposed to rewriting to /wp-admin) ??

    Something like this...

    RewriteRule ^login/?$ /wp-admin [NC,L]
    RewriteRule ^admin/?$ /wp-admin [NC,L]

    The reason I ask is that with the rewrite rule Aaron recommended, typing in domain.com/login ALWAYS takes you back to the login screen, even if you're already logged in.

    If you rewrite it to /wp-admin instead, then typing in domain.com/login will take you straight to /wp-admin if you're already logged in.

  • Jonathan
    • The Incredible Code Injector

    @nickd32,
    Firstly is your rewrite / redirect still working?
    Guess what - mine has stop working - AGAIN! lol. The rewrite rule is fine - can access wp-login.php and /login/ but the redirect just stopped working.

    # Redirect for wp-login.php to /login/
    Redirect 301 /wp-login.php?$ /login/
    # Rewrite wp-login.php to /login/
    RewriteRule ^login/?$ /wp-login.php [NC,L]

    The above httaccess stuff is either working or its not and it goes from one to the other. This is mind boggling - and I am at wits end. All this for a stupid page :slight_frown: *rant over* lol
    If it is still working for you - that means it is my side (hoping it is my side) I've been doing loads of stuff which could have thrown it off :wink:

    As for your question - i think that would be asking for trouble... but rather get final word from Aaron or other dev :wink:

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.