最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

wp admin - Change Dashboard url

matteradmin9PV0评论

How can I change the link to the Dashboard of my WordPress installation from www.mysite/wp-admin to www.mysite/custom-name, without making use of any third party plugin?

I already know that simply changing the wp-admin folder name will not help.

How can I change the link to the Dashboard of my WordPress installation from www.mysite/wp-admin to www.mysite/custom-name, without making use of any third party plugin?

I already know that simply changing the wp-admin folder name will not help.

Share Improve this question edited Nov 4, 2016 at 20:30 nyedidikeke 4921 gold badge6 silver badges15 bronze badges asked Nov 3, 2016 at 6:41 Unnikrishnan RUnnikrishnan R 3613 silver badges15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 5

Without Plugin:

1. Add constant to wp-config.php

define('WP_ADMIN_DIR', 'admin-area');
define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR); 

2. Add below filter to functions.php

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

function wpadmin_filter( $url, $path, $orig_scheme ) {  
    $old  = array( "/(wp-admin)/");  
    $admin_dir = WP_ADMIN_DIR;  
    $new  = array($admin_dir);  
    return preg_replace( $old, $new, $url, 1); 
}

3. Add below line to .htaccess file

RewriteRule ^admin-area/(.*) wp-admin/$1?%{QUERY_STRING} [L]
RewriteRule ^admin-area/?$ /wp-login.php [QSA,L]
RewriteRule ^admin-area/register/?$ /wp-login.php?action=register [QSA,L]
RewriteRule ^admin-area/lostpassword/?$ /wp-login.php?action=lostpassword [QSA,L]

Also you can redirect Using this function

add_action('login_form','redirect_wp_admin');

    function redirect_wp_admin(){
    $redirect_to = $_SERVER['REQUEST_URI'];
        if(count($_REQUEST)> 0 && array_key_exists('redirect_to', $_REQUEST)){
        $redirect_to = $_REQUEST['redirect_to'];
        $check_wp_admin = stristr($redirect_to, 'wp-admin');
                if($check_wp_admin){
                wp_safe_redirect( '404.php' );
                }
        }
    }

Here is a good free plugin Protect Your Admin

NOTE : Back up your database before beginning the activate plugin. It is extremely important to back up your database before beginning the activate plugin.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far