title: disable wp-admin to wp-login canonical redirect (wordpress)
body: <p>I am building a website, with wordpress+buddypress (latest version).</p>
  
  <p>In this website, I have my own custom login|signup|resetpass forms, and I do not want to link them to back-end wp-forms.</p>
  
  <p>I have blocked the back-end forms for all users (default wp-login|signup|resetpass forms)(with a 404 header code)</p>
  
  <p>So if you try to reach wp-admin/wp-login you will see the 404.</p>
  
  <p><strong>I do not want to use any kind of redirection</strong>
  <strong>I want to stop the redirection on a special URL, as to Stop the redirection from that URL to any other URLs</strong>
  <strong>I want to stop redirection from</strong> <strong><code>/wp-admin</code></strong> to <strong><code>/wp-login.php?redirect_to=http%3A%2F%2Fsite.com%2Fwp-admin%2F&amp;reauth=1</code></strong></p>
  
  <p>When you try to reach
  <code>www.example.com/wp-admin</code> and you are not logged in,
  you will <strong>automatically</strong> get redirected to:</p>
  
  <p><code>example.com/wp-login.php?redirect_to=http%3A%2F%2Fsite.com%2Fwp-admin%2F&amp;reauth=1</code></p>
  
  <p><strong>you will get redirected...</strong>
  <strong>the URL will change automatically</strong>
  <strong>this is the default action of wordpress.</strong></p>
  
  <p><strong>I want to stop that automatic redirection</strong>. </p>
  
  <p>When you try to reach /wp-admin, you have to stay at /wp-admin (you should not get a redirect to wp-login).</p>
  
  <p><strong>Please see these 2 pictures for full details</strong>:</p>
  
  <p>Picture 1:</p>
  
  <p><img src="https://i.stack.imgur.com/uRK4P.png" alt="example.com/wp-admin"></p>
  
  <p>Picture 2:</p>
  
  <p><img src="https://i.stack.imgur.com/xbDws.png" alt="you see the url changed automatically"></p>
  
  <p><strong>* NOTE</strong>:</p>
  
  <p>The 404 is something I made to happen..., it's not an error.</p>
  
  <p>I've tested so many codes, to stop it. but none worked for me.</p>
  
  <p>Code number 1:</p>
  
  <pre><code>remove_action('template_redirect', 'redirect_canonical');
  </code></pre>
  
  <p>Code number 2:</p>
  
  <pre><code>remove_filter('template_redirect', 'redirect_canonical');
  </code></pre>
  
  <p>Code number 3:</p>
  
  <pre><code>add_action(
      'init',
      function () {
          remove_action('template_redirect', 'wp_redirect_admin_locations', 1000);
      }
  );
  </code></pre>
  
  <p>Code number 4:</p>
  
  <pre><code>function custom_wp_redirect_admin_locations() {
      global $wp_rewrite;
      if ( ! ( is_404() &amp;&amp; $wp_rewrite-&gt;using_permalinks() ) )
          return;
      $admins = array(
          home_url( 'wp-admin', 'relative' ),
      );
      if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) {
          $wp_query-&gt;set_404();
          get_template_part( 404 ); 
          exit();
      }
      $logins = array(
          home_url( 'wp-login.php', 'relative' )
      );
      if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins ) ) {
          $wp_query-&gt;set_404();
          get_template_part( 404 ); 
          exit();
      }
  }
  
  function remove_default_login_redirect() {
      remove_action('template_redirect', 'wp_redirect_admin_locations', 1000);
      add_action( 'template_redirect', 'custom_wp_redirect_admin_locations', 1000
      );
  }
  add_action('init','remove_default_login_redirect');
  </code></pre>
  
  <p>Code number 5 :</p>
  
  <pre><code>add_action(
      'template_redirect',
      function () {
          $requ = untrailingslashit($_SERVER['REQUEST_URI']);
          if (site_url('wp-admin', 'relative') ===
          untrailingslashit($_SERVER['REQUEST_URI'])) {
              remove_action('template_redirect', 'wp_redirect_admin_locations', 1000);
          }
      }
  );
  </code></pre>
  
  <p>Code number 6:</p>
  
  <pre><code>function custom_wp_redirect_admin_locations() {
      global $wp_rewrite;
      if ( ! ( is_404() &amp;&amp; $wp_rewrite-&gt;using_permalinks() ) )
          return;
  
      $requested_url = untrailingslashit( $_SERVER['REQUEST_URI'] );
  
      $admins = array(
          home_url( 'wp-admin', 'relative' ),
          home_url( 'dashboard', 'relative' ),
          home_url( 'admin', 'relative' ),
          site_url( 'dashboard', 'relative' ),
          site_url( 'admin', 'relative' ),
      );
      if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $admins ) ) {
          redirect_canonical( $requested_url , false );
          exit;
      }
  
      $logins = array(
          home_url( 'wp-login.php', 'relative' )
      );
      if ( in_array( untrailingslashit( $_SERVER['REQUEST_URI'] ), $logins ) ) {
          redirect_canonical( $requested_url , false );
          exit;
      }
  }
  
  function remove_default_login_redirect() {
      remove_action('template_redirect', 'wp_redirect_admin_locations', 1000);
      add_action( 'template_redirect', 'custom_wp_redirect_admin_locations', 
      1000);
  }
  
  add_action('init','remove_default_login_redirect');
  </code></pre>
  
  <p>Whatever I used doesn't seem to be doing the thing I want.
  How can I do it?</p>
  
  <hr>
  
  <p><strong>EDIT : Clarify the context, which is not a duplicate.</strong></p>
  
  <p>The <a href="https://stackoverflow.com/questions/1976781/redirecting-wordpresss-login-register-page-to-a-custom-login-registration-page">link is said as duplicate</a> <strong>clearly saying</strong> that he wants his wp-login pages to get redirect to his own login/registration pages.</p>
  
  <p>But I clearly said "Please read the first 16 lines".
  which means that <strong>I do not try/want to redirect</strong> + <strong>I do not try/want to restrict using any kind of redirection</strong></p>
  
  <p>Plus: I've read all of these articles before posting this. But none of them were the thing that I wanted. So I started a new topic , with full detail.</p>
  
  <p>FYI, I have read 7 more articles (which I picked the codes from them):</p>
  
  <p>But I need at least 10reputations to post more than 2 links! So I cannot say more than 2.</p>
  
  <ol start="2">
  <li><a href="https://wordpress.stackexchange.com/questions/135021/how-to-turn-off-redirection-from-domain-com-login-to-domain-com-wp-login-php/135027#135027">the second article</a></li>
  <li><a href="https://stackoverflow.com/questions/18241408/login-in-permalink-redirects-to-wp-login-php-wp3-6">the third article</a></li>
  <li><a href="https://stackoverflow.com/questions/37569377/wordpress-disable-admin-redirect-to-wp-admin">the fifth article</a></li>
  </ol>
  
  <p>I am grateful for your time and attention, but please read my question one more time with more attention.</p>