How to change the URL of login page in WordPress?

I'm trying to find a way to change my WordPress website's login page URL, any easy way to do it?

Comments

  • 1. Add the following code to wp-config.php:

    define('WP_ADMIN_DIR', 'admin-path');
    define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR);
    

    2. Add the following code 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 the following code to htaccess:

     RewriteRule ^admin-path/(.*) wp-admin/$1?%{QUERY_STRING} [L]

    Or alternatively, you can go to Plugins > Add new and add the WPS Hide Login (https://wordpress.org/plugins/wps-hide-login/) plugin to change the admin URL

Sign In or Register to comment.