How to change WordPress WP-Admin URL

0
1791

Step 1. Finding file wp-config.php in your wordpress root file

and adding 2 these codes:

define('WP_ADMIN_DIR', 'your-custom-folder');
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR);

Step 2. Go to the theme that you are using and open the functions.php file

Add this code to the bottom of the file:

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);
 }

Step 3. You need to declare a new url with .htaccess file so add this code to your htaccess in your website.

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

Hope this helps!