• Resolved Sandip Patil

    (@sandipp)


    Steps:

    1. Add constant to wp-confing.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 ^secret-folder/(.*) wp-admin/$1?%{QUERY_STRING} [L]

    Done…!!!

    Now your admin URL will be like: https://www.yourdomain.com/secret-folder/

Viewing 12 replies - 1 through 12 (of 12 total)
  • Hi there! This would be SUCH A GREAT solution. I came here forwarded by a question I made on Stackoverflow.

    I followed this step by step but still being able to log through /wp-admin and my “secret-folder” shows a 404.

    Any ideas?

    Thanks!

    Thread Starter Sandip Patil

    (@sandipp)

    It works fine for me… Check below code for each file..

    .htacess code:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    Hi there, thanks again for answer me.
    I just followed your structure, I realized that it is working but in a different way I imagined.
    On the initial question I wanted to change the login URL. In this case, if your type your site URL/wp-admin you will still getting the login form, my idea was to move everything to a different path, show a 404 if anyone puts /wp-admin on your site.

    What I found here is that my dashboard is now showing the site.com/secret-folder URL once logged in, but the login form is still shown under /wp-admin and if you type site.com/secret-folder I get a 404.

    Best.

    Thread Starter Sandip Patil

    (@sandipp)

    Put slash at the end of url..
    e.g. : site.com/secret-folder/

    Is there a way to make /wp-admin inaccessible and have /secret-folder/ as the only way to access the login page?

    Thread Starter Sandip Patil

    (@sandipp)

    Yes above code allow you to implement the admin login for url..
    site.com/secret-folder/

    and below code will restrict the URL : site.com/wp-admin

    add_action(‘login_form’,’redirect_wp_admin’);

    function redirect_wp_admin(){
    $redirect_to = $_SERVER[‘REQUEST_URI’];

    if(count($_REQUEST)> 0 && array_key_exists(‘redirect_to’, $_REQUEST)){
    $redirect_to = $_REQUEST[‘redirect_to’];
    $check_wp_admin = stristr($redirect_to, ‘wp-admin’);
    if($check_wp_admin){
    wp_safe_redirect( ‘404.php’ );
    }
    }
    }

    On which file do i put above code??

    This doesnt seem to be working for me. I tried using example.com/admin and it redirects me to example.com/wp-admin

    Which parts of the code do I edit?

    define('WP_ADMIN_DIR', 'admin');
    define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR);
    add_filter('https://www.example.com',  '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);
     }

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

    This is how I edited the code

    I have the same issue a greyblok, whenever I try going to I tried using example.com/admin I get redirected to example.com/wp-admin…

    Also, when adding the code OP posted (to functions.php), I get the following error message:

    Fatal error: Call to undefined function add_filter() in /home1/*****/public_html/site.com/wp-includes/functions.php on line 11

    Thoughts?

    Hello everyone, I currently have a wordpress.com blog now I want to change it over to www.remarpro.com to be included with my website. I have downloaded .org however I can not figure out how to login wpadmin where do I find this.

    @bagladyb: As per the Forum Welcome, please post your own topic. Posting in an existing topic prevents us from being able to track issues by topic. Added to which, your problem – despite any similarity in symptoms – is likely to be completely different.

    Sorry new to this thanks

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘How to change the admin url or wp-admin to secure login’ is closed to new replies.