If your Magento admin is at /admin, every password-guessing bot on the internet knows where to knock. Moving it doesn’t replace strong passwords and two-factor login, but it removes most of the automated noise in one step.
Find the current admin address
bin/magento info:adminuri
Change it
Choose something that is not easy to guess, avoiding words like admin, backend or your store name:
bin/magento setup:config:set --backend-frontname="manage_x7k2"
bin/magento cache:flush
The admin is now at https://your-store.com/manage_x7k2. The old address stops working immediately, so tell your team and update their bookmarks.
The value is stored in app/etc/env.php under backend > frontName. If you deploy env.php from a template, update it there too, or the next deploy will change it back.
Better still: restrict it by IP address
If your team works from fixed IP addresses or a VPN, allow only those to reach the admin. With Nginx:
location ~ ^/(index\.php/)?manage_x7k2 {
allow 203.0.113.10;
deny all;
try_files $uri $uri/ /index.php$is_args$args;
}
Test carefully before relying on it. Locking yourself out means editing the server config to get back in.
Also turn on
- Two-factor authentication for every admin user.
- Account lockout after failed logins (Stores > Configuration > Advanced > Admin > Security).
- reCAPTCHA on the admin login form.
- Admin session timeout of 15 minutes or less.
Catch it automatically
MageMonitor checks for this every few minutes as part of its Security Center checks, and alerts you by email, Slack or webhook the moment it appears, with the exact commands to fix it. See MageMonitor for Magento 2.
