Change the extension / wp-admin to a specific

0

Well, my question is if I can change the url of wordpress / wp-admin for one that for example is called / web-secret, to be able to be without plugins, is that I have found some solutions but I do not get to catch them at all .

Greetings to everyone

    
asked by Dario B. 18.05.2018 в 13:09
source

2 answers

1

You could use the wp_redirect function by adding this snippet of code to the file functions.php

  add_action('init','custom_login');

  function custom_login(){
    global $pagenow;
    if( 'wp-login.php' == $pagenow ) {
    wp_redirect('http://midominio.com/web-secreta');
    exit();
    } 
  }

This initializes the custom-login function that detects if you are accessing the login page and redirects to the desired page.

    
answered by 22.05.2018 / 15:50
source
1

Try this

Note: You must be logged into wordpress first.

1- Go to wp-config.php and add the following:

define('WP_ADMIN_DIR', 'backend');
define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR); 

2- Add this code in the function.php of your theme.

add_filter('site_url',  'wpadmin_filter', 10, 3);

function wpadmin_filter( $url, $path, $orig_scheme ) {
$request_url = $_SERVER['REQUEST_URI'];

$check_wp_admin = stristr($request_url, 'wp-admin');
if($check_wp_admin and !is_user_logged_in()){
    wp_redirect( home_url( '404' ), 302 );
    exit();
}
/**Esto permite mantener la carpeta wp-admin**/
$old  = array( "/(wp-admin)/");
$admin_dir = WP_ADMIN_DIR;
$new  = array($admin_dir);
return preg_replace( $old, $new, $url, 1);
}

add_rewrite_rule( '^' . 'backend/(.*)','wp-admin/$1?%{QUERY_STRING}' ); 
flush_rewrite_rules();

3- Replace the word " backend ", whichever you want. and you sign in as mysitio.com/backend / (with the bar at the end /)

4- Go to Settings - > Permanent links and give to save changes.

That's it. Source: link

    
answered by 25.05.2018 в 11:15