How to change that ‘wp-admin’ URL to something else

By default, every WordPress installation will use example.com/wp-admin as default URL to host the Admin login page and dashboard. It will be harder for visitors to know that you website is powered by WordPress, and it may even increase security as people will not have a clue where your admin login page is.

The first thing that may come to mind is to simply change the wp-admin folder via (S)FTP and call it a day. But this approach can be dangerous, as some links may be broken, and the site can behave very unstable by manually changing the wp-admin URL.

There are basically two approaches to change the wp-admin URL in WordPress that will work well and are safe to do:

Use a Plugin to change the URL

The first approach is the simplest: install the WPS Hide Login plugin. This plugin is easily installed via a couple of clicks and will allow you to, once installed and enabled, set a custom admin URL in WordPress.

WPS Hide Login Plugin
WPS Hide Login Plug-in via WordPress.org website

The plug-in description reads:

WPS Hide Login is a very light plugin that lets you easily and safely change the url of the login form page to anything you want. It doesn’t literally rename or change files in core, nor does it add rewrite rules. It simply intercepts page requests and works on any WordPress website.

WPServeur

Change the WordPress configuration

The second method is a bit more advanced as you will need to adapt some WordPress files via FTP.

You will need to open the following files:

  • wp-config.php: this file can be found in the root of your WordPress installation
  • functions.php: this file can be found in the theme directory of the currently active theme you use
  • .htaccess: this (hidden) file is found in the root of your WordPress installation

For each file, you should add the following information (given you want your new URL to look like: example.com/login):

wp-config.php

You want to define in the WordPress configuration file where the administrator directory is to be found, and change the cookie path:

define('WP_ADMIN_DIR', 'login');  
define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR);  

functions.php

Filter to switch the old with the new URL:

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

.htaccess

We set a redirect at WordPress level for the admin area:

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

 

Author Bio

Thank you for your interest in my blog! On this miniblog, I write mostly short (technical) blog posts that might interest other people. Read more about me or feel free to contact me.

 

Leave a Reply

Your email address will not be published. Required fields are marked *