Let’s have a quick walk through regarding changing Admin URL with WordPress. As we all know that WordPress provides us with less security compared to other CMS and Frameworks. So, in this case, to protect our website from hackers we need to perform several processes like protecting admin area, giving fewer primitives to the database, etc.
If you have a WordPress site, it is straightforward to access the admin URL of the login page. A person with basic knowledge of the best WordPress development services knows that by /wp-admin, you can access the admin page, or by /wp-login.php, you can access the login page. For the security purpose, we need to change Admin URL as well as Login page URL so that it is not easily accessible to others.
There are several plugins available in the market by which we can protect our admin area. Which are as follows:
But, Here I am going to explain to you how we can achieve this using custom code:
You need to follow below three steps to change admin URL:
1) Add constants to wp-config.php file
define('WP_ADMIN_DIR', 'secret-folder');
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR);
2) Add the below snippet in function.php file of your active theme
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 ^secret-folder/(.*) wp-admin/$1?%{QUERY_STRING} [L]
By following the above steps, you can access the admin area using this URL.
Hope this helps you to make things work, feel free to leave your feedback..!!! Need more assistance Hire WordPress Developer…!