Menü schliessen
Created: January 29th 2016
Last updated: May 1st 2020
Categories: IT Development,  IT Support,  Wordpress
Author: Marcus Fleuti

How to change the admin url or wp-admin to secure login in Wordpress

Tags:  Admin,  Security,  wordpress,  wp-admin
Donation Section: Background
Monero Badge: QR-Code
Monero Badge: Logo Icon Donate with Monero Badge: Logo Text
82uymVXLkvVbB4c4JpTd1tYm1yj1cKPKR2wqmw3XF8YXKTmY7JrTriP4pVwp2EJYBnCFdXhLq4zfFA6ic7VAWCFX5wfQbCC

1. Add constant to wp-confing.php

define('WP_ADMIN_DIR', 'your-folder');
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 ^secret-folder/(.*) wp-admin/$1?%{QUERY_STRING} [L]

Your "wp-admin" URL now will be:

www.yoursite.com/your-folder