4

I want to change the login url of my Wordpress install away from /wp-admin.php

I am aiming to do so and am looking at changing the .htaccess file to add in:

RewriteRule ^login$ http://yourdomain.com/wp-login.php [NC, L]

From what I gather however, going to /wp-admin will still allows people to login using that link. I was thinking of doing some sort of PHP redirect so that when the user types in /wp-admin it goes to the 404 not found page.

What is the best way to change the login URL without using a plugin and with the highest security standards?

  • I tink it is much better if you create a custom login page. – cybmeta Sep 3 '14 at 21:27
  • Creating a custom login page does not give you the option to change the URL. It only allows you to change the look and certain parameters. – Travis Patron Sep 3 '14 at 23:02
  • Well, that is not fully true. You still have to send the login form data to wp-login.php, and wp-loning.php direct URL is still available (it is also with .htaccess RewriteRule), but you can use the URL you want for the login page. Just set it up when you create the page as you do with any other page in Wordpress. Maybe you have not fully read the link I posted. Not sure what your goal is but custom login page satisfies the custom URL aspect, plus you can fully customize it. – cybmeta Sep 4 '14 at 6:47
4

There is no sane reason or method to do this "without a plugin", because the code necessary to accomplish the job should be contained within a plugin.

Don't roll your own code, use a tried and tested plugin that is designed specifically for the job. That is the secure way.

0

About changing the login url, i already did by mysel. It help me protect my site and prevent brute force You can change it in htaccess. But you also need to add the filter to replace old login url in wordpress. Example to my website: File .htaccess:


RewriteRule ^signin(.*) wp-login.php?%{QUERY_STRING}

In your theme or custom plugin, you can add the filter to make sure wordpress show the correct login url .


add_filter( 'login_url', 'my_login_page', 10, 2 );
function my_login_page( $login_url, $redirect ) {
    return str_replace("wp-login.php","signin",$login_url);
}

add_action( 'login_form', 'replace_login_submit_form',1); 
function replace_login_submit_form() {
  $your_content = ob_get_contents();
  $your_content = str_replace("wp-login.php","signin",$your_content);  
  ob_get_clean();
  echo $your_content;
}

Hope it can help you!

0

You can use this code:

add_action('init','custom_login');

function custom_login(){
 global $pagenow;
 if( 'wp-login.php' == $pagenow && $_GET['action']!="logout") {
  wp_redirect('http://YOURSITE.com/URL');
  exit();
 }
}
  • 1
    Please add some comments to this. It's bad practise to not give some explanation to answers. – Phill Healey Apr 2 '18 at 20:08
  • this is a redirect, not a new login url. – Tritof Feb 23 at 12:16
0

This can be possible by creating a all new similar file to your existing wp-login.php file. Steps need to follow:

Suggestion: Take a backup of wp-admin.php file before follow the below instruction.

  • Open Your wordpress install location, if it is root just look for file called wp-login.php
  • Now, create a new php file and name it as your new login url i.e. if you want to make your login url www.yoursite.com/iamgaurav instead of www.yoursite.com/wp-admin, so create the new file named: iamgaurav.php
  • Now copy the all codes of existing wp-login.php file & paste it in your new file iamgaurav.php
  • Change all existing instances of wp-login to iamgaurav (easy by bulk replacement option through any editor)
  • Now save this file and remove the original wp-login.php file from root.

You are done. Clear your cache and check the login with new url: www.yoursite.com/iamgaurav

You will get 404 error in case anyone try to login by www.yoursite.com/wp-admin

Hope it helps.

Thanks

  • No. No. Don't alter any of the core files. – De Coder Aug 26 '18 at 9:11

protected by Community Aug 28 '18 at 15:29

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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