How to make the error 404 appear when entering the site / wp-admin address?
I tried to do this:

<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ [OR] RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$ RewriteCond %{REMOTE_ADDR} !^192\.168\.28\.5$ RewriteRule ^(.*)$ - [R=403,L] </IfModule> 

It is necessary to give a 404 error, and to display a 404 error generated by wordpress. (if you use the example I wrote above, it ignores all “get_header, get_sidebar” inserts and so on).
It is impossible for the address bar to change in the address bar (for example: site / 404.php). It should be like with standard wordpress work.

    4 answers 4

    Did you try this method? https://wordpress.org/support/topic/how-to-change-the-admin-url-or-wp-admin-to-secure-login

    1 Add a constant in wp-confing.php

     define('WP_ADMIN_DIR', 'secret-folder'); define('ADMIN_COOKIE_PATH', SITECOOKIEPATH . WP_ADMIN_DIR); 

    2 Add 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 line to .htaccess file

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

      It will be easier to install the plugin, in my opinion only one tick will need to be put in the settings. Name - Lockdown WP. Check the box for: Yes, please hide WP Admin from the user when they are not logg. Below you can specify any other link to the WordPress admin area.

        You can cling to the actions that are responsible for the output of the admin and authorization forms in the wp-login.php file

          add_action('admin_init', 'admin_404'); add_action('login_init', 'admin_404'); //Ограничиваем доступ к админке WP function admin_404() { global $wp_query; if (!current_user_can('manage_options') || !is_user_logged_in()) { if (!defined('DOING_AJAX') || !DOING_AJAX) { $wp_query->set_404(); status_header(404); $template = get_404_template(); if ($template = apply_filters('template_include', $template)) { include($template); } wp_die(); } }} 

          It is necessary to open the wp-admin folder and create a new .htaccess file there. Simply paste the following code into this file: Order Deny, Allow Deny from all Allow from . . . (instead of... specify your IP

          If someone wants to go to the site / wp-admin / see an error 403.