How can I redirect wp-admin to another url

How can I redirect user from wp-admin to another custom page, for example I want to redirect this url:

http://example.com/wp-admin

to:

http://example.com/custom

Related posts

Leave a Reply

3 comments

  1. The easiest way would probably be to create a .htaccess file in your webroot directory.

    Afterwards write this into it:

    Redirect /wp-admin http://www.example.com/custom
    

    Quite self explanatory. Redirect from first link /wp-admin to second link http://www.example.com/custom

    Another way would probably be to use wordpress wp_redirect() function, something like this:

    wp_redirect('http://example.com/custom', $status );
    
  2. Use following code in your functions.php file to redirect to another URL.

    function redirect_login_page(){
    
     // Store for checking if this page equals wp-login.php
     $page_viewed = basename($_SERVER['REQUEST_URI']);
    
     // Where we want them to go
     $login_page  = http://example.com/custom; //Write your site URL here.
     // Two things happen here, we make sure we are on the login page
     // and we also make sure that the request isn't coming from a form
     // this ensures that our scripts & users can still log in and out.
     if( $page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') {
    
     // And away they go...
      wp_redirect($login_page);
      exit();
    
     }
    }
    
    add_action('init','redirect_login_page');