Today I got a little quick tip. Nothing too fancy, but helpful for your clients.
For some of my clients, remembering wp-login.php or even wp-admin isn’t always easy. What I started doing a little while for some of my sites I set it up to allow URL’s like login as a valid URL to the login screen. This is great for simplicity and memorization.
To make this happen we have to get down and dirty with the .htaccess file. In some server setups, like a Windows Server, you probably won’t have this file. Instead, Microsoft uses what’s known as an httpd.conf file. If this is the case this tip may or may not work for you, it all depends on how your server is configured. This is outside the scope of this quick tip unfortunately and requires a tutorial of its own (which I don’t claim to be a Windows Server know-it-all, or an expert server admin), so we will not be looking into this area, sorry!
Add this line to the top of your .htaccess file (above all the WordPress stuff).
# rewrite fake login URL RewriteRule ^login(.*)$ wp-login.php$1
The first line is just a comment. I try my best to always comment my code incase when I revisit I don’t have to think too hard about what’s going on in my code, or if someone else is looking at my work, they too can figure out the logic behind my code. I strongly urge commenting your code :)
The second line is the trick. We define this line as a RewriteRule and using a Regular Expression we tell it to listen for a URL called “Login“, when that URL’s requested, we’ll return the content in the file wp-login.php.
I can go into Regular Expressions but that too is an article of its own. If you find yourself doing a lot of .htaccess work, I highly suggest you get acquainted with it. Regular Expressions are also very common in programming languages to help process complex conditions so a good understanding of them is definitely a good idea :P
And that’s our quick tip! Feel free to change the quick URL to what ever you like. Just replace the word login only and you’ll be safe :)