How To Hide WordPress Admin URL
- Article
- Comment
How To Hide WordPress Admin URL, Hiding admin url becomes more important now a days to prevent the Brute-force attack. Let’s discuss the security measures, which helps you to avoid accessing admin page if the user is not logged in. The following code snippet helps you to prevent brute-force tries.
function kv_prevent_admin_url() { if( !is_user_logged_in() ) ) { wp_die('404 - File not found!', 'File Not Found', array('response' => 404)); } } add_action( 'admin_init', 'kv_prevent_admin_url', 1 );
The above code, makes your site to verify the current user and if no user is logged in and trying to access admin interface, it will redirect them to 404 page- file not found page. But we need to prevent the login page redirect before a user is logged in. So, we need to add one more security measure to prevent the login access.
add_action( 'site_url', 'kv_prevent_admin_url', 1 ); add_action( 'login_url', 'kv_prevent_admin_url', 1 );
If you have any doubt or clarification comment below.