Learn 3 Easy Ways To Change Magento 2 Admin URL Effortlessly

by admin

Are you still using the default Magento 2 admin URL? Have you wondered why there’s a weird string appended to your store’s admin URL? In this blog, I will tell you why that string exists and how to prevent it from your store.

LEAR MORE about changing Magento 2 base URL to optimize your site.


Why should we change Magento 2 admin URL?

When you install Magento 2, it will automatically create an admin URL with a random string. The Magento 2 admin URL allows you to access the backend of the store and then edit and manage the administrative tasks.

Typically, the default Magento 2 admin URL is “yourdomain.com/magento/admin.”

However, the default format is vulnerable to hackers. It is too easy for brute force attacks to crack some common URL names such as backend, admin, etc.

For your information, a brute force attack is where automated software hits your site to try out the predictable username and password combinations in a very short time to try to gain access.


Therefore, in order to protect your site, you should replace the default URL with a complex and unique one.

Using a custom admin URL is actually one of the security best practices recommended by Adobe – the owner of the Magento platform.

Although a custom URL can’t directly protect your site from a hacking attack, it can increase the security of your store and make it harder for bots or hackers to attack it.

And changing the default Magento 2 admin URL is very easy to do. We will introduce you to three different ways to change it in the content below.

Before changing Magento 2 admin URL…

You must make sure that you have a Magento developer on standby before making any changes. There are a lot of cases where people change default admin URLs and then can’t access their admin panel. That’s you need a developer to fix the issue.

Also, to protect your website from going down, it is best to make these edits in a development environment. We recommend contacting your hosting provider to make sure they allow the changing of your Magento admin URL.

Another important note is that you shouldn’t change the Admin URL by yourself if you don’t know how to edit configuration files on the server.

3 ways to change Magento 2 Admin URL

There are three methods to help you change the admin URL with ease. And we will show you all three methods in the content below.

We promise it can be done within a few clicks!

Method #1: Use admin panel configuration.

This is the simplest and easiest method to change the admin URL. 


In your Magento 2 admin panel, access Stores > Settings > Configuration.

1. On the left menu, under the Advanced section, click on Admin.

2. Expand the Admin Base URL section.

3. Set Use Custom Admin URL to “Yes.” Then, enter the Custom Admin URL in the following format: http://yourdomain.com/magento/.

4. Set Custom Admin Path to “Yes.” Then, enter the Custom Admin Path. The path that you enter is appended to the Custom Admin URL after the last forward slash.

Note: The Admin URL must be in the same Commerce installation and have the same document root as the storefront.

5. Click the Save Config button.

6. After saving changes, sign out and log back in using the new Admin URL and path.

Method #2: Change the admin path in Config.php

  1. Log into your server via ssh using an SSH or FTP client. Navigate to the app/etc folder and open the env.php file in a text editor.
  2. Look for the code that says ‘frontName’ and replace the code in the quotes to the right of ‘frontName’ and replace ‘admin’ with your new admin URL.
  3. Flush Cache.
return array (
        ‘backend’  =>
        array (
             ‘frontName’ => ‘admin’, 

Method #3: Change from the Server Command Line

  1. Log in to your Magento hosting server via SSH. Navigate to the root directory of your store.
  2. Run this command: php bin/magento setup:config:set –backend-frontname=“newadminurl”
  3. Within the quotes for backend front name – type in your desired new URL.
  4. If you would like to check or view your admin URL via command line: magento info:adminurl

THE EASIEST SOLUTION >> CHECK OUT our admin URL extension on BSS Magento 2 Plugins list NOW!


Here is a quick guide on how to change Magento 2 admin URL. This needs to be done for security reasons to prevent hacking/cracking issues. After referring to these methods, you can type the new admin URL and log in as usual.

BSS Commerce is one of the leading Magento extension providers and web development services in the world. With experienced and certified Magento developers, we commit to bringing high-quality products and services to optimize our business effectively.

CONTACT NOW to let us know your problems. We are willing to support you every time.

Next Reading Suggestions

© 2019 BSS Commerce owned by THANH CONG INTER ., JSC. All Rights Reserved.
Business registration certificate no. 0106064469 issued by Hanoi Department of Planning and Investment on 19 December 2019.
Legal Representative: Mr. Nguyen Quang Trung.