customization - Change from wp-admin to something else?

admin2025-06-02  1

I have found a couple of plugins which lets me set another URL. For example example/login instead of /wp-admin. But as soon as you go to that adress you are back on /wp-admin. So it is only like a redirect.

How do I change it so that all the url's change too?

I have found a couple of plugins which lets me set another URL. For example example/login instead of /wp-admin. But as soon as you go to that adress you are back on /wp-admin. So it is only like a redirect.

How do I change it so that all the url's change too?

Share Improve this question asked Mar 7, 2018 at 11:34 jockebqjockebq 4631 gold badge6 silver badges18 bronze badges 1
  • Unless you really know what you're doing, you will probably break the site by renaming (plugins may require that structure or need to be changed) – kero Commented Mar 7, 2018 at 13:03
Add a comment  | 

3 Answers 3

Reset to default 4

Generally speaking, you don't. The "wp-admin" is hardcoded in many places.

At WPMU DEV they suggest the following Apache configuration if you need to rename the admin/login pages for security/customization.

# BEGIN Hide login page
RewriteRule ^mylogin$ https://%{SERVER_NAME}/wp-login.php?key=123&redirect_to=https://%{SERVER_NAME}/wp-admin/index.php [L]

RewriteCond %{HTTP_REFERER} !^https://%{SERVER_NAME}/wp-admin
RewriteCond %{HTTP_REFERER} !^https://%{SERVER_NAME}/wp-login.php
RewriteCond %{HTTP_REFERER} !^https://%{SERVER_NAME}/login
RewriteCond %{QUERY_STRING} !^key=123
RewriteCond %{QUERY_STRING} !^action=logout
RewriteCond %{QUERY_STRING} !^action=lostpassword
RewriteCond %{REQUEST_METHOD} !POST
# END Hide login page

Change mylogin to a slug of your choice and 123 to another more secure passphrase.

Credits: https://premium.wpmudev/blog/hide-wordpress-login-page-2/

Steps:

  1. Add constant to wp-config.php

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

Done…!!!

Now your admin URL will be like: http://www.example/securelogin/

Note: put "/" after securelogin

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748826448a314044.html

最新回复(0)