Magento GuideSecurity → Admin Login URL

Change the Magento 2 admin login URL (security checklist)

Changing your Magento 2 admin login URL is one of the easiest ways to block bots and reduce brute force attack attempts. It won’t stop a targeted attacker, but it’s an effective layer of obscurity that helps keep your login screen out of plain sight.

Let’s walk through why this change matters, how to do it safely, and what else you can do to protect your Magento 2 admin panel.

Host Magento at full throttle.

Get secure, reliable Magento hosting so you can scale faster.

Why change the Magento 2 admin login URL?

The default Magento 2 admin login URL is usually something like /admin. Hackers and bots know this, and they’ll often try to brute force their way into your site by targeting this common path with automated login attempts.

Changing the admin login URL makes it harder for attackers to even find your login page. This is called “security through obscurity,” and while it’s not foolproof, it’s a smart first step in any Magento hardening checklist.

Think of it like locking your front door and also moving it to a side alley—not invisible, but less obvious.

Backup your Magento store first

Before making any changes to system files, take a full backup of your Magento store. This ensures you can restore your site if anything goes wrong.

Here’s what to back up:

If your hosting provider offers snapshot backups, take a full snapshot of your environment. If you’re working manually:

Locate the current admin URL in env.php

Magento stores the admin login path in a file called env.php. This is located in the /app/etc/ directory of your Magento installation.

To view or change the admin path:

Use the Magento CLI

Clear Magento cache and test the new URL

Magento uses cached configurations, so your new login path won’t work until you clear the cache.

To do this:

Important: Bookmark this new URL or store it in a password manager. If you forget it, there’s no login link on the frontend, so you’ll need to re-check or re-edit the env.php file to find it again.

Remove or block the default /admin path

Even if your Magento site no longer uses /admin, attackers might still try to access it. You can further secure your store by blocking or redirecting that path.

Here’s how:

Option 1: Redirect to homepage or 404

Option 2: Deny access to /admin

For Apache, add this to your .htaccess:
RedirectMatch 403 ^/admin

For Nginx, add this inside your server block:
location /admin {
deny all;
}

This adds another layer of defense and ensures bots can’t guess their way into your old login path.

Restrict admin access by IP address (optional)

If you work from a fixed location or VPN, you can limit admin access to just your IP address. This is a stronger security measure than simply hiding the login page.

The exact method depends on your server software:

For Apache:

For Nginx:

If your IP changes frequently, skip this step—or use a VPN with a static IP to avoid getting locked out.

Don’t forget to update saved bookmarks and automation

Once your admin login path changes, everything that relied on the old URL will break.

Make sure you:

This avoids confusion later and prevents lockouts for your team or tools.

Top Magento extensions for admin login protection

If you want to go beyond a simple URL change, consider using extensions to add more admin security features. Here are three well-rated options:

FAQ: Magento 2 admin URL questions

Edit the env.php file in /app/etc/ and find the ‘frontName’ value. Change it to a custom string of your choice. Then run php bin/magento cache:flush to apply the change.

By default, it’s yourdomain.com/admin. If you’ve changed the ‘frontName‘ setting in env.php, the new admin login URL will be yourdomain.com/custom-path.

Use the CLI command:

php bin/magento info:adminuri

It will output something like Admin URL: /custom-path so you can find your current login path even if you forgot it.

Next steps for securing your Magento 2 site

Changing your Magento 2 admin login URL is a simple way to reduce your attack surface and stop bots from hammering your login screen. It’s not a complete security solution, but it’s a great start.

Once you’ve changed the URL, follow up by blocking or redirecting the old path and adding extra login protections like reCAPTCHA, IP restrictions, or access logging.

Ready to upgrade your Magento experience? Professional hosting improves speeds, security, and reliability for a website and a brand that people find engaging and trustworthy.

Liquid Web offers the raw infrastructure power you need with mission-critical features that keep your store running smoothly. Most importantly, our in-house Magento experts are standing by to help with both hosting and Magento application roadblocks.

Click through below to explore all of our Magento hosting options, or chat with an expert right now to get answers and advice.

Ready to get started?

Get the fastest, most secure Magento hosting on the market

Additional resources

What is Magento Ecommerce? →

A complete beginner’s guide to the Magento Ecommerce platform

Magento 2 maintenance mode: how to enable/disable →

Understand how to apply Magento security patches to keep your store protected from vulnerabilities and threats.

Best Magento ERP extensions →

Our top 10 compared so you can decide which is best for your business